data2intelligence / SpaCET

Spatial Cellular Estimator for Tumors
GNU General Public License v3.0
40 stars 4 forks source link

SpaCET: Deconvolution with a matched scRNA-seq data set error (works without matched reference) #14

Open dbuszta opened 1 year ago

dbuszta commented 1 year ago

Hi there, when trying to run SpaCET with these data (https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast), I am getting an error at the SpaCET.deconvolution.matched.scRNAseq step of the code. This is the error: [1] "1. Generate the reference from the matched scRNAseq data." Coefficients not estimable: TT WT … Error in chol2inv(fit$qr$qr, size = fit$qr$rank) : 'size' argument must be a positive integer In addition: Warning message: In parallel::mclapply(setdiff(cellTypes_level_1, cellType), run_limma, : all scheduled cores encountered errors in user code)

Do you know what could be causing it? My data works well without the matched reference. I triple-checked all my file inputs from the scRNAseq side and they match the structure of the tutorial exactly. Here is my hierarchical tree: sc_lineageTree <- list("Lymphoid cells" = c("CD4+ T Cells", "CD8+ T Cells", "B Cells"), "Myeloid cells" = c("Mast Cells", "Macrophages 1", "Macrophages 2", "IRF7+ DCs", "LAMP3+ DCs"), "Tumour" = c("Prolif Invasive Tumor", "Invasive Tumor", "T Cell & Tumor Hybrid", "DCIS 1", "DCIS 2"), "Stromal" = c("Stromal", "Stromal & T Cell Hybrid"), "Endothelial" = "Endothelial", "Perivascular-Like" = "Perivascular-Like", "Myoepi" = c("Myoepi ACTA2+", "Myoepi KRT15+"))

Let me know if you need the files I am using and how to best pass them on to you.

beibeiru commented 1 year ago

Hi, Daria,

Can you upload your input of SpaCET.deconvolution.matched.scRNAseq to the following folder? I will figure out the reason soon.

Best, Beibei

dbuszta commented 1 year ago

Hi Beibei,

Just uploaded the files! The outs folder needs to be unzipped first but after you can find my code in the .Rmd.

Let me know if you require further guidance and thanks a lot for your help.

Best, Daria


From: Beibei Ru @.> Sent: 04 May 2023 15:33 To: data2intelligence/SpaCET @.> Cc: Daria Buszta @.>; Author @.> Subject: Re: [data2intelligence/SpaCET] SpaCET: Deconvolution with a matched scRNA-seq data set error (works without matched reference) (Issue #14)

Hi, Daria,

Can you upload your input of SpaCET.deconvolution.matched.scRNAseq to the following folder? I will figure out the reason soon. https://connecthkuhk-my.sharepoint.com/:f:/g/personal/bbru_connect_hku_hk/EgMszyp6ZxREoLhD5TkphXcBTo8xEfgc3YoswsoV96FdpA?e=lUcngf

Best, Beibei

— Reply to this email directly, view it on GitHubhttps://github.com/data2intelligence/SpaCET/issues/14#issuecomment-1534892166, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGBHPOMLSTMSZGHPGRLVZPTXEO44DANCNFSM6AAAAAAXVTUHJU. You are receiving this because you authored the thread.Message ID: @.***>

beibeiru commented 1 year ago

Hi, Daria,

I have fixed the bug and run your code successfully. Please reinstall our package and try again. Just let me know if you have any further questions. BTW, one suggestion is that when building sc_lineageTree, make sure major and sub lineages have different names, e.g., Stromal.

Best, Beibei

dbuszta commented 1 year ago

Perfect thanks a lot!!

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Beibei Ru @.> Sent: Thursday, May 4, 2023 9:05:06 PM To: data2intelligence/SpaCET @.> Cc: Daria Buszta @.>; Author @.> Subject: Re: [data2intelligence/SpaCET] SpaCET: Deconvolution with a matched scRNA-seq data set error (works without matched reference) (Issue #14)

Hi, Daria,

I have fixed the bug and run your code successfully. Please reinstall our package and try again. Just let me know if you have any further questions. BTW, one suggestion is that when building sc_lineageTree, make sure major and sub lineages have different names, e.g., Stromal.

Best, Beibei

— Reply to this email directly, view it on GitHubhttps://github.com/data2intelligence/SpaCET/issues/14#issuecomment-1535265743, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGBHPOPPBHTT73NYT3JIG3LXEP4WFANCNFSM6AAAAAAXVTUHJU. You are receiving this because you authored the thread.Message ID: @.***>

beibeiru commented 1 year ago

Another suggestion is that you might delete the hybrid cells (e.g., "Stromal & T Cell Hybrid" and "T Cell & Tumor Hybrid") in your single-cell reference because you are doing deconvolution and it is better to use pure cell references.

Best, Beibei

dbuszta commented 1 year ago

Hi there, just had another question come up... I tried to visualise genes spatially using this code:

SpaCET.visualize.spatialFeaturehttps://data2intelligence.github.io/SpaCET/reference/SpaCET.visualize.spatialFeature.html(

SpaCET_obj,

spatialType = "GeneExpression",

spatialFeatures = chttps://rdrr.io/r/base/c.html("CD3E","CD3D","CDG", “CD4”, “CD8A”),

nrow=2

)

but getting this error:

[1] "1. Generate the reference from the matched scRNAseq data." [1] "2. Hierarchically deconvolve the Spatial Transcriptomics dataset." [1] "Stage 2 - Level 1. Estimate the major lineage." [1] "Stage 2 - Level 2. Estimate the sub lineage." null device 1 Error in intI(i, n = @.***[1], dn[[1]], give.dn = FALSE) : invalid character indexing Calls: SpaCET.visualize.spatialFeature ... callGeneric -> eval -> eval -> [ -> [ -> subCsp_rows -> intI Execution halted DONE

Thank you for being really helpful. Best, Daria


From: Beibei Ru @.> Sent: 05 May 2023 15:50 To: data2intelligence/SpaCET @.> Cc: Daria Buszta @.>; Author @.> Subject: Re: [data2intelligence/SpaCET] SpaCET: Deconvolution with a matched scRNA-seq data set error (works without matched reference) (Issue #14)

Another suggestion is that you might delete the hybrid cells (e.g., "Stromal & T Cell Hybrid" and "T Cell & Tumor Hybrid") in your single-cell reference because you are doing deconvolution and it is better to use pure cell references.

Best, Beibei

— Reply to this email directly, view it on GitHubhttps://github.com/data2intelligence/SpaCET/issues/14#issuecomment-1536377540, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGBHPOJS3VTCJME3MSMJZT3XEUHVBANCNFSM6AAAAAAXVTUHJU. You are receiving this because you authored the thread.Message ID: @.***>

beibeiru commented 1 year ago

Hi, Daria,

I have fixed it. Please reinstall our package and try again. Thanks.

Best, Beibei

dbuszta commented 1 year ago

This worked perfectly, thank you Beibei!


From: Beibei Ru @.> Sent: 01 June 2023 15:56 To: data2intelligence/SpaCET @.> Cc: Daria Buszta @.>; Author @.> Subject: Re: [data2intelligence/SpaCET] SpaCET: Deconvolution with a matched scRNA-seq data set error (works without matched reference) (Issue #14)

Hi, Daria,

I have fixed it. Please reinstall our package and try again. Thanks.

Best, Beibei

— Reply to this email directly, view it on GitHubhttps://github.com/data2intelligence/SpaCET/issues/14#issuecomment-1572213891, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGBHPOLXA442LHII4Q3TUHDXJCUSPANCNFSM6AAAAAAXVTUHJU. You are receiving this because you authored the thread.Message ID: @.***>

dbuszta commented 1 year ago

Hi Beibei,

I'm slightly confused by the results from the SpaCET.visualize.spatialFeature() function because when I plot the same gene with Seurat's SpatialFeaturePlot() they look different. I know that your function does the log2 transformation but I wouldn't expect it to completely change the expression landscape...

[https://lh3.googleusercontent.com/riD5g-XRFqbAEarBhG0wdJ3tokcVXa8Pk8IE8OaDPtD6UXjKimQ9Ob19qxtHquLo42g920Sgo17LHYHFCbMmO01oiFgK-LQZ_rEDrBEyleM55HZ-qcqBmLIRgr-T7MFra3JQo1ys2_HSVl72A2QUZ5-sFg=s2048] (Seurat) [cid:66ca82b7-1fbf-4883-811f-7f5a68be7d80] (SpaCET)

Do you have any thoughts on this?

Best, Daria


From: Beibei Ru @.> Sent: 01 June 2023 15:56 To: data2intelligence/SpaCET @.> Cc: Daria Buszta @.>; Author @.> Subject: Re: [data2intelligence/SpaCET] SpaCET: Deconvolution with a matched scRNA-seq data set error (works without matched reference) (Issue #14)

Hi, Daria,

I have fixed it. Please reinstall our package and try again. Thanks.

Best, Beibei

— Reply to this email directly, view it on GitHubhttps://github.com/data2intelligence/SpaCET/issues/14#issuecomment-1572213891, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGBHPOLXA442LHII4Q3TUHDXJCUSPANCNFSM6AAAAAAXVTUHJU. You are receiving this because you authored the thread.Message ID: @.***>

beibeiru commented 1 year ago

Hi, Daria,

I will let you know once I figure out the difference between the two visualization methods.

Best, Beibei

beibeiru commented 1 year ago

Hi, Daria,

I design a new parameter scaleTypeForGeneExpression for SpaCET.visualize.spatialFeature, which can help users select different scale modes to visualize gene expression. Please reinstall SpaCET and try it. Just let me know if you have any further questions.

p1 <- SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "GeneExpression", spatialFeatures=c("EPCAM"),scaleTypeForGeneExpression="RawCounts")
p2 <- SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "GeneExpression", spatialFeatures=c("EPCAM"),scaleTypeForGeneExpression="LogRawCounts")
p3 <- SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "GeneExpression", spatialFeatures=c("EPCAM"),scaleTypeForGeneExpression="LogTPM/10")
p4 <- SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "GeneExpression", spatialFeatures=c("EPCAM"),scaleTypeForGeneExpression="LogTPM")

p1+p2+p3+p4+patchwork::plot_layout(nrow = 2)

Best, Beibei

dbuszta commented 11 months ago

Hey Beibei,

Just had another issue. When deleting one gene from the spacet object the whole pipeline fails. Please do you have any advice how to best go about this??

Best, Daria

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Beibei Ru @.> Sent: Thursday, June 8, 2023 7:29:47 PM To: data2intelligence/SpaCET @.> Cc: Daria Buszta @.>; Author @.> Subject: Re: [data2intelligence/SpaCET] SpaCET: Deconvolution with a matched scRNA-seq data set error (works without matched reference) (Issue #14)

Hi, Daria,

I design a new parameter scaleTypeForGeneExpression for SpaCET.visualize.spatialFeature, which can help users select different scale modes to visualize gene expression. Please reinstall SpaCET and try it. Just let me know if you have any further questions.

p1 <- SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "GeneExpression", spatialFeatures=c("EPCAM"),scaleTypeForGeneExpression="RawCounts") p2 <- SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "GeneExpression", spatialFeatures=c("EPCAM"),scaleTypeForGeneExpression="LogRawCounts") p3 <- SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "GeneExpression", spatialFeatures=c("EPCAM"),scaleTypeForGeneExpression="LogTPM/10") p4 <- SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "GeneExpression", spatialFeatures=c("EPCAM"),scaleTypeForGeneExpression="LogTPM")

p1+p2+p3+p4+patchwork::plot_layout(nrow = 2)

Best, Beibei

— Reply to this email directly, view it on GitHubhttps://github.com/data2intelligence/SpaCET/issues/14#issuecomment-1583067358, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGBHPOM2JRSRUUB3G3QYSLTXKIDYXANCNFSM6AAAAAAXVTUHJU. You are receiving this because you authored the thread.Message ID: @.***>

beibeiru commented 11 months ago

Hi, Daria,

I am a little confused about your issue "deleting one gene from the spacet object". Would you please show the codes of what you have run? Thanks.

Best, Beibei

dbuszta commented 11 months ago

visiumPath <- file.path("/home/dbuszta/R/xenium_paper_analysis/spatial_data/CytAssist_FFPE_Human_Breast_Cancer_spatial") SpaCET_obj <- create.SpaCET.object.10X(visiumPath = visiumPath) @.**@.[[1]] <- @.**@*.**@*.**@.[[1]] != "IGKC"] @.**@.[1] <- as.integer(18084) # this was to adjust the dimensions of the object as after removing the gene it didn't match up

The pipeline works if I don't try to delete but it's important for my research to try whether deconvolution is affected by the removal of certain genes so your help would be much appreciated, thank in advance!!


From: Beibei Ru @.> Sent: 24 September 2023 20:26 To: data2intelligence/SpaCET @.> Cc: Daria Buszta @.>; Author @.> Subject: Re: [data2intelligence/SpaCET] SpaCET: Deconvolution with a matched scRNA-seq data set error (works without matched reference) (Issue #14)

Hi, Daria,

I am a little confused about your issue "deleting one gene from the spacet object". Would you please show the codes of what you have run? Thanks.

Best, Beibei

— Reply to this email directly, view it on GitHubhttps://github.com/data2intelligence/SpaCET/issues/14#issuecomment-1732638316, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGBHPOJNYN6WMPRFDRHDTFTX4B3OVANCNFSM6AAAAAAXVTUHJU. You are receiving this because you authored the thread.Message ID: @.***>

beibeiru commented 11 months ago

Hi, Daria,

No worries. I am happy to help you figure out the issue. Can you upload your folder "CytAssist_FFPE_Human_Breast_Cancer_spatial" to the following folder? I will fix it soon. https://connecthkuhk-my.sharepoint.com/:f:/g/personal/bbru_connect_hku_hk/EgOfT89AoZ9CrpKsVG6ObTsB-djuTjxT-v40zwbkWh8mSg?e=3ccKdd

Also, please upload your related codes. 1) how to delete genes 2) how to save ST data after deleting genes 3) how to re-read the ST data

Thanks.

Best, Beibei