satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 910 forks source link

PercentageFeatureSet() error #8082

Closed Changfei6 closed 3 months ago

Changfei6 commented 11 months ago

when i use sc[["percent_MT"]] <- PercentageFeatureSet(sc, pattern = "^MT-|^mt-"), I get the error Error : Error in LayerData(): ! features must be one of "RPL22", "PARK7", "ENO1", "HP1BP3", "CDC42", "RPL11", "SRSF10", "SRRM1", "RSRP1", "SH3BGRL3", "WASF2", "ATP5IF1", "PTP4A2", "SFPQ", "NDUFS5", "MACF1", "YBX1", "RPS8", "PRDX1", "UQCRH", "TMEM59", "JUN", "JAK1", "SERBP1", "SRSF11", "GNG5", "RPL5", "CSDE1", "ATP1A1", "TXNIP", "MCL1", "S100A10", "S100A11", "S100A6", "S100A4", "RPS27", "TPM3", "ASH1L", "SSR2", "LMNA", "TAGLN2", "MGST3", "ATP1B1", "PRRC2C", "GLUL", "ARPC5", "TPR", "ELF3", "BTG2", "NUCKS1", "CD55", "CD46", "ATF3", "H3F3A", "ARF1", "GUK1", "TOMM20", "ARID4B", "HNRNPU", "RPS7", "LAPTM4A", "RHOB", "OST4", "FOSL2", "PPP1CB", "SRSF7", "ZFP36L2", "CALM2", "SPTBN1", "RTN4", "RPS27A", "REL", "ACTR2", "ANXA4", "PCBP1", "TMSB10", "TGOLN2", "COX5B", "EIF5B", "RPL31", "GCC2", "DBI", "MZT2B", "UBXN4", "PPIG", "ATP5MC3", "HNRNPA3", "NFE2L2", "COL3A1", "SF3B1", "HSPD1", "HSPE1", "BZW1", "CFLAR", "EEF1B2", "RPL37A", "ARPC2", "NCL", "PTMA", "LRRFIP1", "SEPT2", "RPL32", "RPL15", "GOLGA4", "RPSA", "RPL14", "NKTR", "TMA7", "RHOA", "RPL29", "SPCS1", "ARL6IP5", "FOXP1", "MTRNR2L12", "RPL24", "ZBTB20", "GOLGB1", "CNBP", "CDV3", "ATP1B3", "TM4SF1", "SERP1", "MBNL1", "CCNL1", "SEC62", "SKIL", "EIF4A2", "LPP", "RPL35A", "ATP5ME", "RPL9", "IGFBP7", "CCNI", "HNRNPDL", "SPARCL1", "H2AFZ", "UBE2D3", "RPL34", "ANXA5", "RPS3A", "SUB1", "RPL37", "GPBP1", "BTF3", "TBCA", "RPS23", "COX7C", "CAST", "HINT1", "UQCRQ", "SKP1", "UBE2B", "DDX46", "EGR1", "CYSTM1", "CSNK1A1", "CD74", "RPS14", "SPARC", "NPM1", "DUSP1", "ATP6V0E1", "HNRNPAB", "HNRNPH1", "CANX", "SQSTM1", "RACK1", "DEK", "HLA-A", "HLA-E", "IER3", "HLA-C", "HLA-B", "CLIC1", "HSPA1A", "RPS18", "RPL10A", "SRSF3", "HSP90AB1", "DST", "EEF1A1", "COX7A2", "PNRC1", "PNISR", "CD164", "RPS12", "EZR", "SOD2", "ACTB", "RAC1", "NDUFA4", "TOMM7", "HNRNPA2B1", "TAX1BP1", "SEPT7", "PPIA", "SEC61G", "CHCHD2", "GTF2I", "HSPB1", "AKAP9", "FAM133B", "COL1A2", "SEM1", "BRI3", "KMT2E", "NAMPT", "CALD1", "NDUFB2", "DNAJB6", "SLC25A6", "CD99", "TMSB4X", "EIF1AX", "SAT1", "DDX3X", "TIMP1", "RBM3", "RPS4X", "ATRX", "COX7B", "TSC22D3", "RPL39", "SSR4", "RPL10", "CTSB", "SARAF", "TACC1", "CEBPD", "RPS20", "SDCBP", "RAB2A", "TRAM1", "RPL7", "UQCRB", "MTDH", "RPL30", "COX6C", "PABPC1", "YWHAZ", "ZNF706", "EIF3E", "LY6E", "EEF1D", "RPL8", "NFIB", "RPS6", "DNAJA1", "CLTA", "ZFAND5", "ANXA1", "HNRNPK", "SEC61B", "TXN", "ATP6V1G1", "GSN", "RPL35", "HSPA5", "RPL12", "LCN2", "SET", "RPL7A", "EDF1", "TUBB4B", "IFITM2", "IFITM3", "RPLP2", "CD151", "POLR2L", "CTSD", "CD81", "KCNQ1OT1", "RPL27A", "MTRNR2L8", "EIF4G2", "C11orf58", "RPS13", "LDHA", "CD59", "CD44", "FTH1", "AHNAK", "COX8A", "FKBP2", "PRDX5", "SF1", "FAU", "NEAT1", "MALAT1", "CFL1", "GSTP1", "SPCS2", "RPS3", "TAF1D", "NNMT", "ATP5MG", "RPS25", "HSPA8", "APLP2", "KLF6", "VIM", "KIF5B", "ITGB1", "JMJD1C", "DDX21", "SRGN", "PPA1", "PSAP", "DDIT4", "RPS24", "TM9SF3", "ATP5MD", "EIF3A", "CD9", "GAPDH", "TPI1", "C12orf57", "YBX3", "EMP1", "MGP", "SCAF11", "SLC38A2", "TUBA1B", "TMBIM6", "LIMA1", "NR4A1", "KRT8", "PFDN5", "PCBP2", "ATP5MC2", "HNRNPA1", "CD63", "RPS26", "RPL41", "MYL6", "PTGES3", "NACA", "RAP1B", "LYZ", "TSPAN8", "NAP1L1", "LUM", "DCN", "BTG1", "SLC25A3", "HSP90B1", "ARPC3", "RPL6", "PEBP1", "RPLP0", "COX6A1", "DYNLL1", "RSRC2", "UBC", "RAN", "MPHOSPH8", "SAP18", "RPL21", "POMP", "HMGB1", "HSPH1", "N4BP2L2", "ELF1", "TSC22D1", "TPT1", "ITM2B", "COMMD6", "ARGLU1", "HNRNPC", "DAD1", "NEDD8", "NFKBIA", "PNN", "RPS29", "RPL36AL", "LGALS3", "KTN1", "SYNE2", "ZFP36L1", "SRSF5", "RBM25", "NPC2", "TMED10", "FOS", "CALM1", "DDX24", "IFI27", "HSP90AA1", "EIF5", "ATP5MPL", "SRP14", "PDIA3", "SERF2", "B2M", "EID1", "ANXA2", "TPM1", "RPS27L", "PPIB", "RPL4", "RPLP1", "PKM", "MORF4L1", "SEC11A", "AKAP13", "CIB1", "IQGAP1", "SELENOS", "RPS2", "SRRM2", "ELOB", "LITAF", "RPS15A", "FUS", "MT2A", "COX4I1", "MAP1LC3B", "CYBA", "APRT", "ANKRD11", "RPL13", "TCF25", "YWHAE", "PFN1", "RPL26", "UBB", "WSB1", "RPL23A", "ZNF207", "RPL23", "RPL19", "IGFBP4", "KRT19", "EIF1", "STAT3", "RPL27", "LUC7L3", "TOB1", "SPAG9", "VMP1", "DDX5", "RPL38", "SUMO2", "H3F3B", "SRSF2", "SOCS3", "TIMP2", "RNF213", "ACTG1", "P4HB", "MYL12A", "MYL12B", "ANKRD12", "VAPA", "FKBP1A", "DSTN", "RRBP1", "CST3", "RBM39", "TOP1", "YWHAB", "ZFAS1", "CEBPB", "PMEPA1", "GNAS", "ATP5F1E", "PSMA7", "RPS21", "PPDPF", "GPX4", "ATP5F1D", "MIDN", "CIRBP", "RPS15", "OAZ1", "GADD45B", "EEF2", "RPL36", "RPS28", "UBL5", "JUNB", "CALR", "IER2", "DNAJB1", "TPM4", "KLF2", "RPL18A", "JUND", "UBA52", "FXYD5", "COX6B1", "SPINT2", "EIF3K", "ACTN4", "ZFP36", "RPS16", "CEACAM6", "RPS19", "RABAC1", "FOSB", "SNRPD2", "NOP53", "SELENOW", "RPL18", "PPP1R15A", "FTL", "RPL13A", "RPS11", "FCGRT", "MYADM", "RPS9", "RPL28", "RPS5", "UQCR10", "MYH9", "LGALS1", "DDX17", "RPL3", "ATF4", "ST13", "RBX1", "SNU13", "TSPO", "ATP5PF", "APP", "SOD1", "SON", "TTC3", "HMGN1", "CSTB", "PTTG1IP", "MT-ND1", "MT-ND2", "MT-CO1", "MT-CO2", "MT-ATP8", "MT-ATP6", "MT-CO3", "MT-ND3", "MT-ND4L", "MT-ND4", "MT-ND5", "MT-ND6", or "MT-CYB", not "counts". Run rlang::last_trace() to see where the error occurred.

sessionInfo() R version 4.2.2 (2022-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux 8.8 (Ootpa)

Matrix products: default BLAS/LAPACK: /nas/longleaf/rhel8/apps/r/4.2.2/lib/libopenblas_haswellp-r0.3.20.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] Seurat_5.0.1 SeuratObject_5.0.0 sp_2.1-1

loaded via a namespace (and not attached): [1] Rtsne_0.16 colorspace_2.1-0 deldir_1.0-9 ellipsis_0.3.2 ggridges_0.5.4 RcppHNSW_0.5.0
[7] rstudioapi_0.15.0 spatstat.data_3.0-3 leiden_0.4.3.1 listenv_0.9.0 remotes_2.4.2.1 ggrepel_0.9.4
[13] RSpectra_0.16-1 fansi_1.0.5 codetools_0.2-19 splines_4.2.2 R.methodsS3_1.8.2 polyclip_1.10-6
[19] spam_2.10-0 jsonlite_1.8.7 ica_1.0-3 cluster_2.1.4 png_0.1-8 R.oo_1.25.0
[25] uwot_0.1.16 shiny_1.8.0 sctransform_0.4.1 spatstat.sparse_3.0-3 compiler_4.2.2 httr_1.4.7
[31] Matrix_1.6-3 fastmap_1.1.1 lazyeval_0.2.2 cli_3.6.1 later_1.3.1 prettyunits_1.2.0
[37] htmltools_0.5.7 tools_4.2.2 igraph_1.5.1 dotCall64_1.1-0 gtable_0.3.4 glue_1.6.2
[43] RANN_2.6.1 reshape2_1.4.4 dplyr_1.1.3 Rcpp_1.0.11 scattermore_1.2 vctrs_0.6.4
[49] spatstat.explore_3.2-5 nlme_3.1-163 progressr_0.14.0 lmtest_0.9-40 spatstat.random_3.2-1 stringr_1.5.1
[55] ps_1.7.5 globals_0.16.2 mime_0.12 miniUI_0.1.1.1 lifecycle_1.0.4 irlba_2.3.5.1
[61] goftest_1.2-3 future_1.33.0 MASS_7.3-60 zoo_1.8-12 scales_1.2.1 promises_1.2.1
[67] spatstat.utils_3.0-4 parallel_4.2.2 RColorBrewer_1.1-3 reticulate_1.34.0 pbapply_1.7-2 gridExtra_2.3
[73] ggplot2_3.4.4 stringi_1.8.1 fastDummies_1.7.3 pkgbuild_1.4.2 rlang_1.1.2 pkgconfig_2.0.3
[79] matrixStats_1.1.0 lattice_0.22-5 ROCR_1.0-11 purrr_1.0.2 tensor_1.5 patchwork_1.1.3
[85] htmlwidgets_1.6.2 processx_3.8.2 cowplot_1.1.1 tidyselect_1.2.0 parallelly_1.36.0 RcppAnnoy_0.0.21
[91] plyr_1.8.9 magrittr_2.0.3 R6_2.5.1 generics_0.1.3 pillar_1.9.0 fitdistrplus_1.1-11
[97] survival_3.5-7 abind_1.4-5 tibble_3.2.1 future.apply_1.11.0 crayon_1.5.2 KernSmooth_2.23-22
[103] utf8_1.2.4 spatstat.geom_3.2-7 plotly_4.10.3 grid_4.2.2 data.table_1.14.8 callr_3.7.3
[109] digest_0.6.33 xtable_1.8-4 tidyr_1.3.0 httpuv_1.6.12 R.utils_2.12.2 munsell_0.5.0
[115] viridisLite_0.4.2

sc[["percent_MT"]] <- PercentageFeatureSet(sc, pattern = "^MT-|^mt-")
wangchuanyuan1 commented 11 months ago

Me too, this only seems to happen in the latest version (V5.0.0)

menage95 commented 10 months ago

I am also having this issue after updating packages - did you find a resolution?

menage95 commented 10 months ago

UPDATE: after installing the development version of Signac to solve another bug, this issue also didn't happen again

mhkowalski commented 10 months ago

Hi, I am not able to reproduce this with the latest versions of Seurat (5.0.1) and SeuratObject (5.0.1). Could you please try upgrading and let me know if the issue persists/ provide a reproducible example?

hyhy200g commented 9 months ago

I have the same issue at the latest versions of Seurat (5.0.1) and SeuratObject (5.0.1)

klgoss commented 9 months ago

Did anyone find a resolution to this? I'm having the same issue with code that used to work and now getting this error since updating to V5.

victorjima commented 9 months ago

Hello, I have been experiencing this issue for two days and I finally sorted it out by updating Signac to github version (I also updated SeuratData and others). Hope it works for you!

Nglab commented 8 months ago

So same thing happened to me (installing scCustomize might have been the culprit but I am not 100% certain). I have tried reinstalling Seurat and Signac but it didn't work for me. The way I fixed this without digging deep into the code or finding out which package(s) needs updating/re-updating was clearing out my user libPath and rebuilt all the packages (for me, it was just Seurat, Signac, and EnsDb.Hsapiens.v86) from scratch.

Clara22 commented 7 months ago

In case you don't want to update to the Signac github version, providing the features / gene names instead of a pattern to PercentageFeatureSet worked for me:

#Create a vector with the gene names you want to work with, in this case any gene name in the 'counts' slot starting with 'mt-'
selgenes<-rownames(SEU@assays$RNA@counts)[grepl(pattern="^mt-",rownames(SEU@assays$RNA@counts))]

The selgenes vector looks like this (I am working with a mouse dataset, hence the lowercase)

selgenes [1] "mt-Nd1" "mt-Nd2" "mt-Co1" "mt-Co2" "mt-Atp8" "mt-Atp6" "mt-Co3" [8] "mt-Nd3" "mt-Nd4l" "mt-Nd4" "mt-Nd5" "mt-Nd6" "mt-Cytb"

#Run PercentageFeatureSet giving the vector of gene names to features
SEU <- PercentageFeatureSet(SEU, features=selgenes, assay="RNA", col.name="percent.mt")
zm2647 commented 6 months ago

@Clara22 I followed your code above,but there was an error like this

selgenes<-rownames(seurat_merge@assays$RNA@counts)[grepl(pattern="^MT-",rownames(seurat_merge@assays$RNA@counts))] seurat_merge[["percent.mt"]] <- PercentageFeatureSet(seurat_merge, assay="RNA", features=selgenes, col.name="percent.mt") Error in [<-.data.frame(*tmp*, , i, value = new("Seurat", assays = list( : There are 58715 rows in the replacement data, but the data is 33145 do you know what the problem is?

zm2647 commented 6 months ago

and I found 58715 is the rowcount of seurat_merge@assays$RNA, 33145 is the colcount

igrabski commented 3 months ago

Closing this issue since it seems that re-installing to the versions provided above resolves the problem -- please feel free to open a new issue if problems persist.