dviraran / SingleR

SingleR: Single-cell RNA-seq cell types Recognition (legacy version)
GNU General Public License v3.0
260 stars 95 forks source link

Create SingleR object from an existing seurat object #115

Open naamama opened 4 years ago

naamama commented 4 years ago

Hi, I'm trying to run: singler <- CreateSinglerObject(counts=GetAssayData(MyObject, slot="counts"), annot = NULL, project.name="object_filtered", min.genes = 0, technology = "X10", species = "Human", citation = "", ref.list = list(), normalize.gene.length = F, variable.genes = "de", fine.tune = T,
do.signatures = T, clusters = NULL, do.main.types = T, reduce.file.size = T, numCores = 8)

but got this error (same error appeared with SingleR.CreateObject function: Error in CreateSinglerObject(counts = GetAssayData(MyObject, : could not find function "CreateSinglerObject" Execution halted

  1. Has the function "CreateSinglerObject" been changed in the latest version of SingleR? or there is a new name for the function that creates SingleR object from existing Seurat object?
  2. Does it have something to do with the fact that my R studio version is now 3.6.1? (singleR most updated version was installed after this R update)

Any help will be appreciated! Thank you! Naama

MediciPrime commented 4 years ago

Hi @naamama I am not part of the SingleR team but I assume you installed SingleR using the Bioconductor release. In that case I would ignore the guides on this Github repository and focus on the vignette from the SingleR bioconductor page. The 'CreateSinglerObject' has been removed when the code was rewritten and you now need to use SingleR. Its actually an awesome rewrite with very fast processing of even large data sets.

Here is the vignette.

Goodluck!

naamama commented 4 years ago

Thank you very much @MediciPrime! Good to know, I'll try SingleR(). Is there a way to add this SingleR object to an exist Seurat? or the new SingleR has to be totally independent?

dtm2451 commented 4 years ago

Hi @naamama,

The SingleR output is now a simple DataFrame, but you can easily copy the main outputs into a Seurat as metadata using:

# Say this was part of your code for the SingleR run:
results <- SingleR(test = as.SingleCellExperiment(seurat_obj), ...)

# Copy over the labels and pruned.labels (Note: any other column of the results could be used as well)
seurat_obj$SingleR.pruned.calls <- results$pruned.labels
seurat_obj$SingleR.calls <- results$labels

After that, you will be able to access, and use for plotting in the same way as any other Seurat metadata, any of the metadata slots created from the SingleR results!

naamama commented 4 years ago

Great! thank you very much

tonimaried commented 3 years ago

Hello,

I converted a h5ad file into a Seurat object. I am now trying to convert that into a singlecellexperiment so I can use singleR. results <- SingleR(test = as.SingleCellExperiment(LymphNodes_result), ref=hpca.se, assay.type.test=1, labels = hpca.se$label.main))

I get the following error: Error in method(object) : all assays must have the same nrow and ncol

Does anyone have any thoughts? One catch is that I can't update R and other packages so I'm trying to work with the packages that I have below.

And potentially of note, when I convert h5ad file , I get the following messages: sys:1: FutureWarning: The 'getvalues' method is deprecated and will be removed in a future version Warning: Feature names cannot have underscores (''), replacing with dashes ('-') Warning message: In SetAssayData.Assay(object = object[[assay]], slot = slot, new.data = new.data) : Adding features not currently present in the object

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

other attached packages: [1] scRNAseq_2.0.2 celldex_0.99.1
[3] usethis_1.5.0 devtools_2.0.2
[5] patchwork_1.0.1.9000 SingleR_1.0.6
[7] DropletUtils_1.6.1 SingleCellExperiment_1.8.0 [9] SummarizedExperiment_1.16.1 DelayedArray_0.12.3
[11] BiocParallel_1.20.1 matrixStats_0.56.0
[13] Biobase_2.46.0 GenomicRanges_1.38.0
[15] GenomeInfoDb_1.22.1 IRanges_2.20.2
[17] S4Vectors_0.24.4 BiocGenerics_0.32.0
[19] stringr_1.4.0 GSA_1.03.1
[21] gplots_3.0.1.1 Matrix_1.2-17
[23] dplyr_0.8.0.1 Seurat_3.0.0.9000
[25] cowplot_0.9.4 ggplot2_3.3.2
[27] reticulate_1.12

loaded via a namespace (and not attached): [1] backports_1.1.8 AnnotationHub_2.18.0
[3] BiocFileCache_1.10.2 plyr_1.8.4
[5] igraph_1.2.4.1 lazyeval_0.2.2
[7] splines_3.6.0 listenv_0.7.0
[9] digest_0.6.25 htmltools_0.3.6
[11] fansi_0.4.1 gdata_2.18.0
[13] magrittr_1.5 memoise_1.1.0
[15] cluster_2.0.8 ROCR_1.0-7
[17] remotes_2.0.4 limma_3.42.2
[19] globals_0.12.4 R.utils_2.8.0
[21] prettyunits_1.1.1 colorspace_1.4-1
[23] blob_1.1.1 rappdirs_0.3.1
[25] ggrepel_0.8.1 callr_3.4.3
[27] crayon_1.3.4 RCurl_1.95-4.12
[29] jsonlite_1.6 survival_2.44-1.1
[31] zoo_1.8-5 ape_5.3
[33] glue_1.4.1 gtable_0.3.0
[35] zlibbioc_1.32.0 XVector_0.26.0
[37] pkgbuild_1.1.0 Rhdf5lib_1.8.0
[39] future.apply_1.2.0 HDF5Array_1.14.4
[41] scales_1.1.1 DBI_1.0.0
[43] edgeR_3.28.1 bibtex_0.4.2
[45] Rcpp_1.0.1 metap_1.1
[47] viridisLite_0.3.0 xtable_1.8-4
[49] dqrng_0.2.0 bit_1.1-14
[51] rsvd_1.0.0 SDMTools_1.1-221.1
[53] tsne_0.1-3 htmlwidgets_1.3
[55] httr_1.4.0 RColorBrewer_1.1-2
[57] ellipsis_0.3.1 ica_1.0-2
[59] farver_2.0.3 pkgconfig_2.0.3
[61] R.methodsS3_1.7.1 dbplyr_1.4.0
[63] locfit_1.5-9.1 labeling_0.3
[65] tidyselect_0.2.5 rlang_0.4.7
[67] later_0.8.0 AnnotationDbi_1.48.0
[69] munsell_0.5.0 BiocVersion_3.10.1
[71] tools_3.6.0 cli_2.0.2
[73] RSQLite_2.1.1 ExperimentHub_1.12.0
[75] ggridges_0.5.1 yaml_2.2.0
[77] npsurv_0.4-0 fs_1.3.1
[79] processx_3.4.3 bit64_0.9-7
[81] fitdistrplus_1.0-14 caTools_1.17.1.2
[83] purrr_0.3.2 RANN_2.6.1
[85] pbapply_1.4-0 future_1.13.0
[87] nlme_3.1-139 mime_0.6
[89] R.oo_1.22.0 compiler_3.6.0
[91] plotly_4.9.0 curl_3.3
[93] png_0.1-7 interactiveDisplayBase_1.24.0 [95] testthat_2.3.2 lsei_1.2-0
[97] tibble_3.0.3 stringi_1.4.3
[99] ps_1.3.4 desc_1.2.0
[101] lattice_0.20-38 vctrs_0.3.2
[103] pillar_1.4.6 lifecycle_0.2.0
[105] BiocManager_1.30.4 Rdpack_0.11-0
[107] lmtest_0.9-37 BiocNeighbors_1.4.2
[109] data.table_1.12.2 bitops_1.0-6
[111] irlba_2.3.3 gbRd_0.4-11
[113] httpuv_1.5.1 R6_2.4.1
[115] promises_1.0.1 KernSmooth_2.23-15
[117] sessioninfo_1.1.1 codetools_0.2-16
[119] pkgload_1.1.0 MASS_7.3-51.4
[121] gtools_3.8.1 assertthat_0.2.1
[123] rhdf5_2.30.1 rprojroot_1.3-2
[125] withr_2.2.0 GenomeInfoDbData_1.2.2
[127] grid_3.6.0 tidyr_0.8.3
[129] DelayedMatrixStats_1.8.0 Rtsne_0.15

dviraran commented 3 years ago

Please post the question at https://github.com/LTLA/SingleR

tonimaried commented 3 years ago

Done. thanks.