satijalab / seurat

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

can we show the orig.ident in separate windows by using Seurat #2106

Closed naixiangxiaozi closed 5 years ago

naixiangxiaozi commented 5 years ago

I'm curious about can we show the orig.ident in sprat windows by using Seurat? Here are my code and the fig I got. Is it possible that I can separate each orig.ident into a single panel like the Loupe Cell Browser can split each org.ident separate in single windows as shown in the fig?

DimPlot(whole,group.by = "orig.ident", reduction = "umap"

image

timoast commented 5 years ago

You can use the split.by option in DimPlot

naixiangxiaozi commented 5 years ago

Hi, do you mean that I can use spilt.by="orig.ident"?


From: Tim Stuart notifications@github.com Sent: Monday, September 16, 2019 10:56 AM To: satijalab/seurat seurat@noreply.github.com Cc: Li, Hua hli28@tulane.edu; Author author@noreply.github.com Subject: Re: [satijalab/seurat] can we show the orig.ident in separate windows by using Seurat (#2106)

External Sender. Be aware of links, attachments and requests.

You can use the split.by option in DimPlot

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsatijalab%2Fseurat%2Fissues%2F2106%3Femail_source%3Dnotifications%26email_token%3DAKCY2ATMMYS5CICBFAEWGF3QJ6UBBA5CNFSM4IW3BWYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6ZT47A%23issuecomment-531840636&data=02%7C01%7Chli28%40tulane.edu%7C04ec7d74cdb04fb00cfd08d73abe5f00%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042461617871378&sdata=J7stGyz7LtdTaohjg9RRM5NLKE2JeR6ut3jOur7MFWI%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKCY2AT3Z5OFBAX4PJCAP53QJ6UBBANCNFSM4IW3BWYA&data=02%7C01%7Chli28%40tulane.edu%7C04ec7d74cdb04fb00cfd08d73abe5f00%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042461617881374&sdata=uArSBLnF%2BT6ZKyM%2BuvwKmDouS2yD%2B5VR4vlxzxEfdPc%3D&reserved=0.

timoast commented 5 years ago

@naixiangxiaozi yes

naixiangxiaozi commented 5 years ago

If I used the code below"

DimPlot(whole,spilt.by="orig.ident", reduction = "umap") ", I got the picture that only showed the cluster number as in the screenshot. Is there anything I still need to do?

[cid:19102082-826a-4302-8ade-d865eeb71063]

Best, Hua


From: Tim Stuart notifications@github.com Sent: Monday, September 16, 2019 12:03 PM To: satijalab/seurat seurat@noreply.github.com Cc: Li, Hua hli28@tulane.edu; Mention mention@noreply.github.com Subject: Re: [satijalab/seurat] can we show the orig.ident in separate windows by using Seurat (#2106)

External Sender. Be aware of links, attachments and requests.

@naixiangxiaozihttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnaixiangxiaozi&data=02%7C01%7Chli28%40tulane.edu%7C8d2b3754f3644d16335e08d73ac7c7cb%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042502031283062&sdata=3U0CbiIipt6%2B693O9Nh%2FFZvr2%2Fxm5LnXLl1z6SgP7Lw%3D&reserved=0 yes

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsatijalab%2Fseurat%2Fissues%2F2106%3Femail_source%3Dnotifications%26email_token%3DAKCY2AVH65XMJKCQLMNN2FLQJ635TA5CNFSM4IW3BWYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6Z2KBA%23issuecomment-531866884&data=02%7C01%7Chli28%40tulane.edu%7C8d2b3754f3644d16335e08d73ac7c7cb%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042502031293059&sdata=7XzDjg7wodxLwRkfO3y1MefskRmlAeYdbRoXxdcAagY%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKCY2AVDNBVVHULDNH2PJOLQJ635TANCNFSM4IW3BWYA&data=02%7C01%7Chli28%40tulane.edu%7C8d2b3754f3644d16335e08d73ac7c7cb%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042502031293059&sdata=7UzVmeuG1mfUCrqIyrCGcE7DxSUaEHUJHWlowTtbdqY%3D&reserved=0.

timoast commented 5 years ago

I don't see the screenshot, but you will need to set split.by to whatever column in the Seurat metadata that you want to split the cells by.

You can look at the documentation for DimPlot and at the tutorials we have on the Seurat website for more information: https://satijalab.org/seurat/vignettes.html

naixiangxiaozi commented 5 years ago

I have tried to reedit the code from the beginning to add the genotype as below: "

wt@meta.data$genotype<-"WT"

Nkx2_5_KO@meta.data$genotype<-"Nkx2-5-KO"

Shox2_KO@meta.data$genotype<-"Shox2-KO"

Double_KO@meta.data$genotype <-"Double-KO"

"

And using the dimplot with the spilt.by="genotype" as below code:

"

DimPlot(whole,spilt.by="genotype", reduction = "umap")

"

Then it still got the picture in the whole as below:

[cid:549acda1-9e50-41da-b8fe-615049f7359e]

Could you please give me some more advice?

Thank you,

Hua


From: Tim Stuart notifications@github.com Sent: Monday, September 16, 2019 1:47 PM To: satijalab/seurat seurat@noreply.github.com Cc: Li, Hua hli28@tulane.edu; Mention mention@noreply.github.com Subject: Re: [satijalab/seurat] can we show the orig.ident in separate windows by using Seurat (#2106)

External Sender. Be aware of links, attachments and requests.

I don't see the screenshot, but you will need to set split.by to whatever column in the Seurat metadata that you want to split the cells by.

You can look at the documentation for DimPlot and at the tutorials we have on the Seurat website for more information: https://satijalab.org/seurat/vignettes.htmlhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsatijalab.org%2Fseurat%2Fvignettes.html&data=02%7C01%7Chli28%40tulane.edu%7Cd197b2b264e348bbf7e108d73ad64d55%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042564409657877&sdata=uKkckKK3Ou0gz%2FUs538iwW4ZM4kJbY5E3fBI153rdy4%3D&reserved=0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsatijalab%2Fseurat%2Fissues%2F2106%3Femail_source%3Dnotifications%26email_token%3DAKCY2AQM6MTA3HEBBVV36XTQJ7IDLA5CNFSM4IW3BWYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD62EFHQ%23issuecomment-531907230&data=02%7C01%7Chli28%40tulane.edu%7Cd197b2b264e348bbf7e108d73ad64d55%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042564409667879&sdata=V790sg3vaHTi2DsRgPV%2BMBo2oHufl0NIGTXc%2FIzVfuM%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKCY2ASXUM5LJ54AM7VUAYDQJ7IDLANCNFSM4IW3BWYA&data=02%7C01%7Chli28%40tulane.edu%7Cd197b2b264e348bbf7e108d73ad64d55%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042564409677870&sdata=FRAczeshaZ2Q2mGvycWi2fjqk8Uc7mWuSpj68xN5cjM%3D&reserved=0.

timoast commented 5 years ago

Again, the screenshot is not included so it's hard to know what the problem is here. Please attach the plot properly and post the full code you're using.

naixiangxiaozi commented 5 years ago
library(Seurat)
library(dplyr)
library(Matrix)
wt.data <- Read10X("~/Shox2cre_mtmg_S5_GFP/outs/filtered_feature_bc_matrix")
wt <-CreateSeuratObject(count= wt.data, project = "wt_with_GFP",min.cells = 3, min.features = 200)
Nkx2_5_KO.data <- Read10X("~/NKX2_5_KO_GFP/outs/filtered_feature_bc_matrix")
Nkx2_5_KO <-CreateSeuratObject(count= Nkx2_5_KO.data, project = "Nkx2_5_KO_with_GFP",min.cells = 3, min.features = 200)
Shox2_KO.data <- Read10X("~/Shox2crecre_mtmg1_GFP/outs/filtered_feature_bc_matrix")
Shox2_KO <-CreateSeuratObject(count= Shox2_KO.data, project = "Shox2_KO_with_GFP",min.cells = 3, min.features = 200)
Double_KO.data <- Read10X("~/Shox2crecre_Nkx2_5FF_mtmg_S3_GFP/outs/filtered_feature_bc_matrix")
Double_KO <-CreateSeuratObject(count= Double_KO.data, project = "Double_KO_with_GFP",min.cells = 3, min.features = 200)
wt@meta.data$genotype<-"WT"
Nkx2_5_KO@meta.data$genotype<-"Nkx2-5-KO"
Shox2_KO@meta.data$genotype<-"Shox2-KO"
Double_KO@meta.data$genotype <-"Double-KO"
whole <- merge(x = wt, y = list(Nkx2_5_KO, Shox2_KO, Double_KO))
whole[["percent.mt"]] <- PercentageFeatureSet(whole, pattern = "^mt-")
VlnPlot(whole, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), nCol = 3)
plot1 <- FeatureScatter(whole, feature1 = "nCount_RNA", feature2 = "percent.mt")
plot2 <- FeatureScatter(whole, feature1 = "nCount_RNA", feature2 = "nFeature_RNA")
CombinePlots(plots = list(plot1, plot2))
whole <- subset(whole, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)
whole <- NormalizeData(whole, normalization.method = "LogNormalize", scale.factor = 10000)
whole <- FindVariableFeatures(whole, selection.method = "vst", nfeatures = 2000)
top10 <- head(VariableFeatures(whole), 10)
plot1 <- VariableFeaturePlot(whole)
plot2 <- LabelPoints(plot = plot1, points = top10, repel = TRUE)
CombinePlots(plots = list(plot1, plot2))
all.genes <- rownames(whole)
whole<- ScaleData(whole, features = all.genes)
whole <- RunPCA(whole, features = VariableFeatures(object = whole))
print(whole[["pca"]], dims = 1:5, nfeatures = 5)
VizDimLoadings(whole, dims = 1:2, reduction = "pca")
DimPlot(whole, reduction = "pca")
DimHeatmap(whole, dims = 1, cells = 500, balanced = TRUE)
DimHeatmap(whole, dims = 1:15, cells = 500, balanced = TRUE)
ElbowPlot(whole)
whole <- FindNeighbors(whole, dims = 1:10)
whole <- FindClusters(whole, resolution = 0.5)
head(Idents(whole), 5)
whole <- RunUMAP(whole, dims = 1:10)
DimPlot(whole,split_by = "genotype", reduction = "umap")

image

timoast commented 5 years ago

You're using split_by, the correct argument is split.by (. not _)

naixiangxiaozi commented 5 years ago

Or, sorry for the copy error. Actually, my code is using split.by.


From: Tim Stuart notifications@github.com Sent: Monday, September 16, 2019 6:03 PM To: satijalab/seurat seurat@noreply.github.com Cc: Li, Hua hli28@tulane.edu; Mention mention@noreply.github.com Subject: Re: [satijalab/seurat] can we show the orig.ident in separate windows by using Seurat (#2106)

External Sender. Be aware of links, attachments and requests.

You're using splitby, the correct argument is split.by (. not )

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsatijalab%2Fseurat%2Fissues%2F2106%3Femail_source%3Dnotifications%26email_token%3DAKCY2AVE7HJUUZHNRBPJFWDQKAGE3A5CNFSM4IW3BWYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD62YUMQ%23issuecomment-531991090&data=02%7C01%7Chli28%40tulane.edu%7C961234e015554ec1e1dc08d73afa1e79%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042718259441093&sdata=2EgC%2Betm%2FASKJDMRMaHx5xGK6WTBuXsR%2Bk%2Bl%2FfAW5wA%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKCY2ARQELAMUTIGLW7XC5LQKAGE3ANCNFSM4IW3BWYA&data=02%7C01%7Chli28%40tulane.edu%7C961234e015554ec1e1dc08d73afa1e79%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C1%7C637042718259451087&sdata=GncRxlPEnorx%2FRj%2Fr9y2s1327C2Tk6z7G8DLfSFRefE%3D&reserved=0.

timoast commented 5 years ago

Can you show the output of head(whole[[]])?

mojaveazure commented 5 years ago

@naixiangxiaozi You cannot attach images via email and have them show up here. If you want to paste a screenshot, you have to use the website.

naixiangxiaozi commented 5 years ago

image

timoast commented 5 years ago

I can't reproduce this. Can you run this code and show the output:

library(Seurat)
DimPlot(pbmc_small, split.by = 'letter.idents')
sessionInfo()
naixiangxiaozi commented 5 years ago

image Hi, thank you for your help. And by the way after using "split.by = 'letter.idents' ", I got the same dimplot picture as before.

timoast commented 5 years ago

Please enter the exact code shown above and post the entire output here

naixiangxiaozi commented 5 years ago

I've using cypress to run Rscript, and got the following session information. And the attached file is the dimplot I got.

R version 3.5.2 (2018-12-20) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS release 6.5 (Final)

Matrix products: default BLAS/LAPACK: /share/apps/intel_parallel_studio_xe/2015_update1/composer_xe_2015.1.133/mkl/lib/intel64/libmkl_intel_lp64.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] 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] Matrix_1.2-15 ggplot2_3.2.1 dplyr_0.8.3 Seurat_3.1.0

loaded via a namespace (and not attached): [1] nlme_3.1-137 tsne_0.1-3 bitops_1.0-6 [4] RcppAnnoy_0.0.12 RColorBrewer_1.1-2 httr_1.4.1 [7] sctransform_0.2.0 tools_3.5.2 backports_1.1.4 [10] R6_2.4.0 irlba_2.3.3 KernSmooth_2.23-15 [13] uwot_0.1.3 lazyeval_0.2.2 colorspace_1.4-1 [16] withr_2.1.2 npsurv_0.4-0 tidyselect_0.2.5 [19] gridExtra_2.3 compiler_3.5.2 plotly_4.9.0 [22] labeling_0.3 caTools_1.17.1.2 scales_1.0.0 [25] lmtest_0.9-37 ggridges_0.5.1 pbapply_1.4-2 [28] stringr_1.4.0 digest_0.6.20 R.utils_2.9.0 [31] pkgconfig_2.0.2 htmltools_0.3.6 bibtex_0.4.2 [34] htmlwidgets_1.3 rlang_0.4.0 zoo_1.8-6 [37] jsonlite_1.6 ica_1.0-2 gtools_3.8.1 [40] R.oo_1.22.0 magrittr_1.5 Rcpp_1.0.2 [43] munsell_0.5.0 ape_5.3 reticulate_1.13 [46] lifecycle_0.1.0 R.methodsS3_1.7.1 stringi_1.4.3 [49] gbRd_0.4-11 MASS_7.3-51.1 gplots_3.0.1.1 [52] Rtsne_0.15 plyr_1.8.4 grid_3.5.2 [55] parallel_3.5.2 gdata_2.18.0 listenv_0.7.0 [58] ggrepel_0.8.1 crayon_1.3.4 lattice_0.20-38 [61] cowplot_1.0.0 splines_3.5.2 SDMTools_1.1-221.1 [64] zeallot_0.1.0 pillar_1.4.2 igraph_1.2.4.1 [67] future.apply_1.3.0 reshape2_1.4.3 codetools_0.2-15 [70] leiden_0.3.1 glue_1.3.1 lsei_1.2-0 [73] metap_1.1 data.table_1.12.2 RcppParallel_4.4.3 [76] vctrs_0.2.0 png_0.1-7 Rdpack_0.11-0 [79] gtable_0.3.0 RANN_2.6.1 purrr_0.3.2 [82] tidyr_1.0.0 future_1.14.0 assertthat_0.2.1 [85] rsvd_1.0.2 RSpectra_0.15-0 survival_2.43-3 [88] viridisLite_0.3.0 tibble_2.1.3 cluster_2.0.7-1 [91] globals_0.12.4 fitdistrplus_1.0-14 ROCR_1.0-7

image

timoast commented 5 years ago

That UMAP is not from the pbmc_small data, so you're either not running the code above or you're not looking at the correct plot.

naixiangxiaozi commented 5 years ago

oh, I see. you mean that I need to try the PBMCs_small data? ok, I will try.

Best, Hua


From: Tim Stuart notifications@github.com Sent: Thursday, September 19, 2019 1:08 PM To: satijalab/seurat seurat@noreply.github.com Cc: Li, Hua hli28@tulane.edu; Mention mention@noreply.github.com Subject: Re: [satijalab/seurat] can we show the orig.ident in separate windows by using Seurat (#2106)

External Sender. Be aware of links, attachments and requests.

That UMAP is not from the pbmc_small data, so you're either not running the code above or you're not looking at the correct plot.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsatijalab%2Fseurat%2Fissues%2F2106%3Femail_source%3Dnotifications%26email_token%3DAKCY2ATW7WMPRSTZZ3Y7KCLQKO5YFA5CNFSM4IW3BWYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7EK5TA%23issuecomment-533245644&data=02%7C01%7Chli28%40tulane.edu%7C2459818158b84556823108d73d2c505f%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C0%7C637045132840108203&sdata=I%2Boui0aLxwR4797mK%2Fhcz9%2F1pyaGLXxVkDd1%2Fxvo1Ys%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKCY2AUSPHILCUBETUPYU5LQKO5YFANCNFSM4IW3BWYA&data=02%7C01%7Chli28%40tulane.edu%7C2459818158b84556823108d73d2c505f%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C0%7C637045132840118198&sdata=4qLz9muXpiMI0WpHGxQiU4gfN9k83MpAiotS6uAGvMc%3D&reserved=0.

naixiangxiaozi commented 5 years ago

Hi here is my output: image image

timoast commented 5 years ago

Again, not sure what this is but it's not pbmc_small. All you need to do is copy and paste those lines into R and show the resulting plot. Here they are again:

library(Seurat)
DimPlot(pbmc_small, split.by = 'letter.idents')
naixiangxiaozi commented 5 years ago

Hi finally, I think that I have know what you want me to do. And the screenshot is the output I got. Thank you so much! image

naixiangxiaozi commented 5 years ago

Hi Tim, I would like to know whether it is a bug or I do something wrong?


From: Tim Stuart notifications@github.com Sent: Thursday, September 19, 2019 3:15 PM To: satijalab/seurat seurat@noreply.github.com Cc: Li, Hua hli28@tulane.edu; Mention mention@noreply.github.com Subject: Re: [satijalab/seurat] can we show the orig.ident in separate windows by using Seurat (#2106)

External Sender. Be aware of links, attachments and requests.

Again, not sure what this is but it's not pbmc_small. All you need to do is copy and paste those lines into R and show the resulting plot. Here they are again:

library(Seurat) DimPlot(pbmc_small, split.by = 'letter.idents')

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsatijalab%2Fseurat%2Fissues%2F2106%3Femail_source%3Dnotifications%26email_token%3DAKCY2AXURDJDLWXCJU627PDQKPMV7A5CNFSM4IW3BWYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7EWHGA%23issuecomment-533291928&data=02%7C01%7Chli28%40tulane.edu%7Ca7dd035f3a614135fffa08d73d3e1cc6%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C0%7C637045209286777145&sdata=UKrHkwpom0RMB8Wit%2Fu%2FVzMrJwtTJxoxOs%2BZneocphA%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKCY2ARGZ5KMV5JO6KZYQRDQKPMV7ANCNFSM4IW3BWYA&data=02%7C01%7Chli28%40tulane.edu%7Ca7dd035f3a614135fffa08d73d3e1cc6%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C0%7C637045209286777145&sdata=rcnaWDxnq1hEup91dN1cZqd6wjOcLyEko%2FrDp5HpAEs%3D&reserved=0.