Coder Social home page Coder Social logo

powellgenomicslab / nebulosa Goto Github PK

View Code? Open in Web Editor NEW
66.0 66.0 6.0 270 KB

R package to visualize gene expression data based on weighted kernel density estimation

R 100.00%
single-cell single-cell-analysis single-cell-multiomics single-cell-rna-seq

nebulosa's People

Contributors

beigelk avatar gokceneraslan avatar joseah avatar mojaveazure avatar nturaga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nebulosa's Issues

What is the optimal threshold value of joint density?

Dear Nebulosa group:
Thanks for your wonderful work in single cell visualization!
I've found that for well expressed markers, there's great performance.
But for some obviously wrong combinations, it will show a bad result,because of the joint density value.
What is the best threshold? Can I adjust the maximum value manually?

Rplot1
Rplot2

Can you make it compatible to ggplot2v3.5?

I get this error while plotting densities-
Error in scCustomize::Plot_Density_Custom():
! Due to error in Nebulosa package and ggplot2 v3.5.0 Plot_Density_Custom functionality is currently
restricted to ggplot v3.4.4 or lower.
Run rlang::last_trace() to see where the error occurred.

I assume the Nebulosa package is not updated with latest version of ggplot2?

spatstat exports issue

This seems to be new:

R> library(Nebulosa)
Loading required package: patchwork
Registered S3 method overwritten by 'spatstat.geom':
  method     from
  print.boxx cli 
Error: package or namespace load failed for 'Nebulosa':
 object 'markvario' is not exported by 'namespace:spatstat'

It can be overcome by installing an old version of spatstat, which is (perhaps obviously) not a sustainable approach.

Introduce split.by?

Hi,
Thanks for this very handy tool for cluster exploration. It would be most useful if a "split.by" function could be added to Nebulosa, with behaviour similar to Seurat's split.by options for featureplot & dimplot, where plots can be partitioned by the factors/levels that are provided.
ggplot2 facet_wrap() will take plot_density output and split by factor:
plot_density(someSeuratObject, "CD4") + facet_wrap(someSeuratObject$orig.ident)
but as Nebulosa density is calculated feature-wise for all cells in the object, the Nebulosa viridus overlay is duplicated and overlayed on each facet.
So, something like:
plot_density(someSeuratObject, "CD4", split.by = "orig.ident") would be nice, with densities calculated for each "orig.ident" and overlayed accordingly.
This would be a really nice addition and provide a naming convention from Seurat.

Make function density_plot to work smoothly with genes that have only zero read counts

Dear Nebulosa developers,

Nice tool. I work with Nebulosa_1.8.0. One suggestion for improvement: If you run the function plot_density on a gene that has only zero counts, it currently throws a rather cryptic error and doesn't produce any plot:

Error in linbin2D.ks(x, gpoints[[1]], gpoints[[2]], w = w) :
NA/NaN/Inf in foreign function call (arg 10)
In addition: Warning message:
In ks.defaults(x = x, w = w, binned = binned, bgridsize = bgridsize, :
Weights don't sum to sample size - they have been scaled accordingly

Instead, the function could check the read counts and in case they are all zero generate a simple plot with all dots of color = zero counts omitting the density estimation in this case.

Background: I want to use Nebulosa in a script that runs automatically over genes and it may happen in a few cases that all their read counts are zero.

A few of advices for this package

Hi ,
Thanks to develop the great tools to visulize the scRNA data.
I hope the plot_density function can add the split_by parameter in it to display different group data.
Besides, i hope the plot_density's legend can set the real value not the converted value ?
Hope the package best,
hanhuihong

plot_density not working

I've used plot_density several times but today I ran into this error and couldn't find more details about it. Is it possible related to the recent Seurat update?

library(Nebulosa)
Loading required package: ggplot2
Loading required package: patchwork
data <- SeuratObject::pbmc_small
plot_density(data,"CD3E")
Error in as.vector(x, "character") :
cannot coerce type 'environment' to vector of type 'character'
sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.3.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] Nebulosa_1.12.0 patchwork_1.2.0 ggplot2_3.5.0

loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-3 rstudioapi_0.15.0 jsonlite_1.8.8
[4] magrittr_2.0.3 spatstat.utils_3.0-4 farver_2.1.1
[7] zlibbioc_1.48.0 vctrs_0.6.5 ROCR_1.0-11
[10] spatstat.explore_3.2-6 RCurl_1.98-1.14 S4Arrays_1.2.0
[13] htmltools_0.5.7 SparseArray_1.2.3 pracma_2.4.4
[16] sctransform_0.4.1 parallelly_1.37.0 KernSmooth_2.23-22
[19] htmlwidgets_1.6.4 ica_1.0-3 plyr_1.8.9
[22] plotly_4.10.4 zoo_1.8-12 igraph_2.0.2
[25] mime_0.12 lifecycle_1.0.4 pkgconfig_2.0.3
[28] Matrix_1.6-5 R6_2.5.1 fastmap_1.1.1
[31] GenomeInfoDbData_1.2.11 MatrixGenerics_1.14.0 fitdistrplus_1.1-11
[34] future_1.33.1 shiny_1.8.0 digest_0.6.34
[37] colorspace_2.1-0 S4Vectors_0.40.2 Seurat_5.0.1
[40] tensor_1.5 RSpectra_0.16-1 irlba_2.3.5.1
[43] GenomicRanges_1.54.1 labeling_0.4.3 progressr_0.14.0
[46] fansi_1.0.6 spatstat.sparse_3.0-3 httr_1.4.7
[49] polyclip_1.10-6 abind_1.4-5 compiler_4.3.2
[52] withr_3.0.0 fastDummies_1.7.3 MASS_7.3-60.0.1
[55] DelayedArray_0.28.0 tools_4.3.2 lmtest_0.9-40
[58] httpuv_1.6.14 future.apply_1.11.1 goftest_1.2-3
[61] glue_1.7.0 nlme_3.1-164 promises_1.2.1
[64] grid_4.3.2 Rtsne_0.17 cluster_2.1.6
[67] reshape2_1.4.4 generics_0.1.3 gtable_0.3.4
[70] spatstat.data_3.0-4 tidyr_1.3.1 data.table_1.15.0
[73] sp_2.1-3 utf8_1.2.4 XVector_0.42.0
[76] BiocGenerics_0.48.1 spatstat.geom_3.2-8 RcppAnnoy_0.0.22
[79] ggrepel_0.9.5 RANN_2.6.1 pillar_1.9.0
[82] stringr_1.5.1 spam_2.10-0 RcppHNSW_0.6.0
[85] later_1.3.2 splines_4.3.2 dplyr_1.1.4
[88] lattice_0.22-5 survival_3.5-8 deldir_2.0-2
[91] ks_1.14.2 tidyselect_1.2.0 SingleCellExperiment_1.24.0
[94] miniUI_0.1.1.1 pbapply_1.7-2 gridExtra_2.3
[97] IRanges_2.36.0 SummarizedExperiment_1.32.0 scattermore_1.2
[100] stats4_4.3.2 Biobase_2.62.0 matrixStats_1.2.0
[103] stringi_1.8.3 lazyeval_0.2.2 codetools_0.2-19
[106] tibble_3.2.1 cli_3.6.2 uwot_0.1.16
[109] xtable_1.8-4 reticulate_1.35.0 munsell_0.5.0
[112] Rcpp_1.0.12 GenomeInfoDb_1.38.5 globals_0.16.2
[115] spatstat.random_3.2-2 png_0.1-8 parallel_4.3.2
[118] ellipsis_0.3.2 mclust_6.1 dotCall64_1.1-1
[121] bitops_1.0-7 listenv_0.9.1 mvtnorm_1.2-4
[124] viridisLite_0.4.2 scales_1.3.0 ggridges_0.5.6
[127] crayon_1.5.2 SeuratObject_5.0.1 leiden_0.4.3.1
[130] purrr_1.0.2 rlang_1.1.3 cowplot_1.1.3

Layering Nebulosa Visualization with Clustering Results

Hello,

Thank you for publishing this tool! I've really enjoyed how easily this package can visualize feature expression based on kernel density estimation.

Could you add a function to layer the nebulosa and clustering visualizations? While this can be accomplished using ggplot2, the code tends to be a little clunky (definitely my fault) and not readily scalable when trying to annotate datasets that are large and/or relatively complex (in that multiple cell types are present == many clusters). Having a function that easily generates this layered visualization would help cut down ggplot2 troubleshooting and better align the nebulosa and clustering results.

Thank you for your time,
Marc

Does Nebulosa support the visualization of CITE-seq data?

Hi Jose,

Thank you for creating this wonderful new package! I was wondering if it could be used to visualize the marker gene and antibody expression data from CITE-seq simultaneously, just like the FeaturePlot function in Seurat? I tried to read the source code but was not sure how plot_density() can search both RNA and ADT assay for expression data at the same time.

Thanks,
Lei

Prepare for upcoming Seurat v5 release

I am opening this issue as a notification because Nebulosa is listed here as a package that relies (depends/imports/suggests) on Seurat. As you may know, we recently released Seurat v5 as a beta in March of this year, with new updates for spatial, multimodal, and massively scalable analysis. For more information on updates and improvements, check out our website https://satijalab.org/seurat/.
We are now preparing to release Seurat v5 to CRAN, and plan to submit it on October 23rd. While we have tried our best to keep things backward-compatible, it is possible that updates to Seurat and SeuratObject might break your existing functionality or tests. We wanted to reach out before the new version is on CRAN, so that there's time to report issues/incompatibilities and prepare you for any changes in your code base that might be necessary.

We apologize for any disruption or inconvenience, but hope that the improvements to Seurat v5 will benefit your users going forward.
To test the upcoming release, you can install Seurat from the seurat5 branch using the instructions available on this page: https://satijalab.org/seurat/articles/install.

Thank you!
Seurat v5 team

Plot density issue

Hi,

I tried to use plot_density function but I didn't get any plot or error.

Code:

`p4 <- plot_density(SeuOs, c("Il21r", "Il2rb"), joint = TRUE)

p4 + plot_layout(ncol = 1)
SeuOs
An object of class Seurat
31061 features across 51442 samples within 2 assays
Active assay: RNA (31053 features, 2000 variable features)
3 layers present: counts, data, scale.data
1 other assay present: HTO
3 dimensional reductions calculated: pca, tsne, umap`

Screenshot 2024-04-19 at 3 36 19 PM

What do you suspect?

Thank you,
Aastha

Nebulosa with Module Scores?

I have recently been using Nebulosa to show the density of gene set enrichment module scores.
Although it doesn't appear the tool was designed specifically for this, when given module scores the tool returns a useful map often more obviously highlighting regions of enrichment (when compared to FeaturesPlots in Seurat).

What are the suggestions for using the Nebulosa tool for module scores?

plot_density can't work

data <- SeuratObject::pbmc_small
plot_density(data,"CD3E")
Error in plot_density(data, "CD3E")

sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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

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

other attached packages:
[1] Nebulosa_1.4.0 SeuratObject_4.0.4 Seurat_4.1.0 patchwork_1.1.1 ggplot2_3.3.5
[6] clusterProfiler_4.3.2.991 RcisTarget_1.10.0 DOSE_3.16.0 SummarizedExperiment_1.20.0 Biobase_2.50.0
[11] GenomicRanges_1.42.0 GenomeInfoDb_1.26.7 IRanges_2.24.1 S4Vectors_0.28.1 BiocGenerics_0.36.1
[16] MatrixGenerics_1.2.1 matrixStats_0.61.0

loaded via a namespace (and not attached):
[1] utf8_1.2.2 ks_1.13.3 reticulate_1.24 R.utils_2.11.0 tidyselect_1.1.1
[6] RSQLite_2.2.9 AnnotationDbi_1.52.0 htmlwidgets_1.5.4 grid_4.0.0 BiocParallel_1.24.1
[11] Rtsne_0.15 devtools_2.4.3 scatterpie_0.1.7 munsell_0.5.0 codetools_0.2-16
[16] ica_1.0-2 future_1.23.0 miniUI_0.1.1.1 withr_2.4.3 colorspace_2.0-2
[21] GOSemSim_2.16.1 rstudioapi_0.13 SingleCellExperiment_1.12.0 ROCR_1.0-11 tensor_1.5
[26] listenv_0.8.0 labeling_0.4.2 GenomeInfoDbData_1.2.4 polyclip_1.10-0 bit64_4.0.5
[31] farver_2.1.0 rprojroot_2.0.2 downloader_0.4 parallelly_1.30.0 vctrs_0.3.8
[36] generics_0.1.2 R6_2.5.1 graphlayouts_0.8.0 hdf5r_1.3.5 bitops_1.0-7
[41] spatstat.utils_2.3-0 cachem_1.0.6 fgsea_1.16.0 DelayedArray_0.16.3 promises_1.2.0.1
[46] scales_1.1.1 ggraph_2.0.5 enrichplot_1.10.2 gtable_0.3.0 globals_0.14.0
[51] processx_3.5.2 goftest_1.2-3 tidygraph_1.2.0 rlang_1.0.0 splines_4.0.0
[56] lazyeval_0.2.2 spatstat.geom_2.3-1 BiocManager_1.30.16 reshape2_1.4.4 abind_1.4-5
[61] httpuv_1.6.5 SeuratDisk_0.0.0.9019 qvalue_2.22.0 usethis_2.1.5 tools_4.0.0
[66] feather_0.3.5 ellipsis_0.3.2 spatstat.core_2.3-2 RColorBrewer_1.1-2 sessioninfo_1.2.2
[71] ggridges_0.5.3 Rcpp_1.0.8 plyr_1.8.6 zlibbioc_1.36.0 purrr_0.3.4
[76] RCurl_1.98-1.5 ps_1.6.0 prettyunits_1.1.1 rpart_4.1-15 deldir_1.0-6
[81] pbapply_1.5-0 viridis_0.6.2 cowplot_1.1.1 zoo_1.8-9 ggrepel_0.9.1
[86] cluster_2.1.0 fs_1.5.2 magrittr_2.0.2 data.table_1.14.2 scattermore_0.7
[91] DO.db_2.9 lmtest_0.9-39 RANN_2.6.1 mvtnorm_1.1-3 fitdistrplus_1.1-6
[96] pkgload_1.2.4 hms_1.1.1 mime_0.12 xtable_1.8-4 XML_3.99-0.8
[101] mclust_5.4.9 AUCell_1.12.0 gridExtra_2.3 testthat_3.1.2 compiler_4.0.0
[106] tibble_3.1.6 KernSmooth_2.23-16 crayon_1.4.2 shadowtext_0.1.1 R.oo_1.24.0
[111] htmltools_0.5.2 ggfun_0.0.5 mgcv_1.8-31 later_1.3.0 tidyr_1.2.0
[116] DBI_1.1.2 tweenr_1.0.2 MASS_7.3-51.5 Matrix_1.4-0 brio_1.1.3
[121] cli_3.1.1 R.methodsS3_1.8.1 igraph_1.2.11 pkgconfig_2.0.3 plotly_4.10.0
[126] spatstat.sparse_2.1-0 annotate_1.68.0 XVector_0.30.0 yulab.utils_0.0.4 stringr_1.4.0
[131] callr_3.7.0 digest_0.6.29 pracma_2.3.6 sctransform_0.3.3 RcppAnnoy_0.0.19
[136] graph_1.68.0 spatstat.data_2.1-2 leiden_0.3.9 fastmatch_1.1-3 uwot_0.1.11
[141] GSEABase_1.52.1 curl_4.3.2 shiny_1.7.1 lifecycle_1.0.1 nlme_3.1-147
[146] jsonlite_1.7.3 desc_1.4.0 viridisLite_0.4.0 fansi_1.0.2 pillar_1.6.5
[151] lattice_0.20-41 fastmap_1.1.0 httr_1.4.2 pkgbuild_1.3.1 survival_3.1-12
[156] GO.db_3.12.1 remotes_2.4.2 glue_1.6.1 png_0.1-7 bit_4.0.4
[161] ggforce_0.3.3 stringi_1.7.6 blob_1.2.2 memoise_2.0.1 dplyr_1.0.7
[166] irlba_2.3.5 future.apply_1.8.1

Nebulosa with metadata

Hello,

Thanks so much for publishing this tool, very cool way to look at gene expression!

Is there a way to look at metadata instead? I have a large integrated seurat object and I would like to create a figure with the density plot indicating where the cells from each of the samples/experiments falls on the UMAP.

Thanks!

Carly

Can Nebulosa be used from seurat object normalized via NormalizeData() instead of SCTransform()?

Hello! From this tutorial, the steps start with creating the seurat object, where the normalization step is via SCTransform.

Can I use a seurat object that is already normalized, clustered, cell-identified, and fully processed? When I skip the pre-processing and go directly to use plot_density(), the plot shows a PCA plot, whereas if I use the FeaturePlot, it shows a UMAP plot.

How can I make it so that the already-processed seurat object will show the density plot with already-clustered UMAP visualization?

https://bioconductor.org/packages/devel/bioc/vignettes/Nebulosa/inst/doc/nebulosa_seurat.html#

Nebulosa for multimodal data

Hi

Thanks to develop the great tools to visulize the scRNA data.

Is there a way to visualize CITE-seq data and mRNA data with Nebulosa? I did not find it.

best

Felipe

Problems trying to generate a kernel density plot with more than 2 genes

I want to generate a Kernel Density plot with my scRNAseq data for a particular list of genes. The vignette of this package shows you an example plotting the join density of 2 genes. I have been checking the documentation and it doesn't seem that you have a limit of genes to plot.

However, when I try to add more genes (<2)... I am having problems (it doesn't generate anything).

Example:

library(Seurat)
library(Nebulosa)
data <- SeuratObject::pbmc_small
data <- RunPCA(data)
data <- RunUMAP(data, dims = 1:10)
data <- FindNeighbors(data, dims = 1:10)
data <- FindClusters(data)

# it works
p4 <- plot_density(data, c("CD8A", "RUFY1"), joint = TRUE)
p4 + plot_layout(ncol = 1)

Captura de pantalla 2024-06-27 154517

If I add more genes,, it generates an empty plot (it doesn't give me any error)

p4 <- plot_density(data, c("CD8A", "CCR7", "VDAC3", "TREML1", "CA2", "SDPR", "PPBP", "IGLL5", "GNLY", "CD1C", "S100A9", "RUFY1"), joint = TRUE)
p4 + plot_layout(ncol = 1)

My environment:

  • R version 4.2.2 (2022-10-31 ucrt)
  • Nebulosa_1.0.1
  • patchwork_1.2.0
  • ggplot2_3.5.1
  • SeuratObject_4.1.3
  • Seurat_4.3.0

Could anybody help me, please? Any feedback will be well received.

Thanks very much in advance!

Plot density issue for >1 gene and the projection output

Hello,
I'm using Seurat v5 with an RDS object obtained by using the BBKNN integration protocol. The Plot_density function does not generate a plot for more than one gene, and for a single gene, it produces a t-SNE projection instead of a UMAP projection. Please advise on how to resolve this issue? Thank you for any help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.