Seurat: PercentageFeatureSet function not found

Created on 5 Apr 2019  Â·  11Comments  Â·  Source: satijalab/seurat

The Seurat 3.0 Guided Clustering tutorial uses PercentageFeatureSet(), but when I attempt to call it I get the error
Error in PercentageFeatureSet(object = data, pattern = "MT-") : could not find function "PercentageFeatureSet"

Here's the output from sessionInfo(), confirming that I am using Seurat 3

R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /n/apps/CentOS7/install/r-3.5.2/lib64/R/lib/libRblas.so
LAPACK: /n/apps/CentOS7/install/r-3.5.2/lib64/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] dplyr_0.8.0.1 knitr_1.21 shiny_1.2.0 pryr_0.1.4 Seurat_3.0.0.9000

loaded via a namespace (and not attached):
[1] nlme_3.1-137 tsne_0.1-3 bitops_1.0-6 RColorBrewer_1.1-2 httr_1.4.0 tools_3.5.2 R6_2.4.0
[8] irlba_2.3.3 KernSmooth_2.23-15 lazyeval_0.2.1 colorspace_1.4-0 withr_2.1.2 npsurv_0.4-0 tidyselect_0.2.5
[15] compiler_3.5.2 Cairo_1.5-9 plotly_4.8.0 labeling_0.3 caTools_1.17.1.1 scales_1.0.0 lmtest_0.9-36
[22] ggridges_0.5.1 pbapply_1.4-0 stringr_1.4.0 digest_0.6.18 rmarkdown_1.11 R.utils_2.8.0 pkgconfig_2.0.2
[29] htmltools_0.3.6 bibtex_0.4.2 htmlwidgets_1.3 rlang_0.3.1 rstudioapi_0.9.0 zoo_1.8-4 jsonlite_1.6
[36] ica_1.0-2 gtools_3.8.1 R.oo_1.22.0 magrittr_1.5 Matrix_1.2-15 Rcpp_1.0.0 munsell_0.5.0
[43] ape_5.2 reticulate_1.10 R.methodsS3_1.7.1 stringi_1.3.1 yaml_2.2.0 gbRd_0.4-11 MASS_7.3-51.1
[50] gplots_3.0.1.1 Rtsne_0.15 plyr_1.8.4 grid_3.5.2 parallel_3.5.2 gdata_2.18.0 listenv_0.7.0
[57] promises_1.0.1 ggrepel_0.8.0 crayon_1.3.4 lattice_0.20-38 cowplot_0.9.4 splines_3.5.2 SDMTools_1.1-221
[64] pillar_1.3.1 igraph_1.2.4 future.apply_1.1.0 codetools_0.2-16 glue_1.3.0 evaluate_0.13 lsei_1.2-0
[71] metap_1.1 data.table_1.12.0 png_0.1-7 httpuv_1.4.5.1 Rdpack_0.10-1 gtable_0.2.0 RANN_2.6.1
[78] purrr_0.3.0 tidyr_0.8.2 future_1.11.1.1 assertthat_0.2.0 ggplot2_3.1.0 xfun_0.4 rsvd_1.0.0
[85] mime_0.6 xtable_1.8-3 later_0.8.0 rsconnect_0.8.13 survival_2.43-3 viridisLite_0.3.0 tibble_2.0.1
[92] cluster_2.0.7-1 globals_0.12.4 fitdistrplus_1.0-14 ROCR_1.0-7`

Thanks!

All 11 comments

We've just added this function very recently, so please make sure you have the absolute latest Seurat v3 install

has it been committed yet to the public release/3.0 yet, because it is still not there.

I copied and pasted the above PercentageFeatureSet function and my R Studio is not happy with the "%| |%" notation in the function:

Error in assay %||% DefaultAssay(object = object) :
could not find function "%||%"

Any advice on this? Sorry if this is particularly simple; I'm pretty new to R.

Thanks in advance!

@piepertc If you install the very latest Seurat that requires compiling, it appears to have PercentageFeatureSet() working fine. If you'd rather not update just yet, it looks like you're missing a tiny helper function hidden elsewhere in the larger utilities.R file. Try adding

# Set a default value if an object is null
#
# @param lhs An object to set if it's null
# @param rhs The value to provide if x is null
#
# @return rhs if lhs is null, else lhs
#
# @author Hadley Wickham
# @references https://adv-r.hadley.nz/functions.html#missing-arguments
#
`%||%` <- function(lhs, rhs) {
  if (!is.null(x = lhs)) {
    return(lhs)
  } else {
    return(rhs)
  }
}

to your code and see if that fixes it.

@0x644BE25 That does seem to have circumvented the %||% issue, but now a new problem is arising with the PercentFeatureSet Function:

Error in colSums(x = GetAssayData(object = object, slot = "counts")[features, :
'x' must be an array of at least two dimensions

I find that line in the PercentFeatureSet code but I am not entirely sure what changes to make.

I really appreciate your help!

Also of note, I believe I am using the most recent version of Seurat:

packageVersion("Seurat")
[1] ‘3.0.0.9000’

is this correct?

For what it's worth, I'm having the same "Error in PercentageFeatureSet(rpe, pattern = "^MT-") :
could not find function "PercentageFeatureSet" issue, version 3.0.0.9 updated just now.

The current version of Seurat is 3.0.1. Please install that version and try again

Hi, I have Seurat version ‘3.0.2’

I still get the error message "could not find function "PercentageFeatureSet" "

Any advice?

I restarted R and that seems to have solved the problem. However, as I have now updated the Seurat package, the following features can no longer be found in the seurat object- nGene and nUMI

Have they been renamed?
Thanks for helping!

Seems that loading the Matrix package solved the issue for me: library('Matrix')

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igordot picture igordot  Â·  3Comments

camilliano picture camilliano  Â·  3Comments

RuiyangLiu94 picture RuiyangLiu94  Â·  3Comments

milanmlft picture milanmlft  Â·  3Comments

kysbbubbu picture kysbbubbu  Â·  3Comments