data2intelligence / SpaCET

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

SpaCET.deconvolution.matched.scRNAseq error #3

Open BenjaminDEMAILLE opened 1 year ago

BenjaminDEMAILLE commented 1 year ago

Hi !

I trie to deconvolute and I got this error :

Error in ST[1, ] : subscript out of bounds

2.  SpatialDeconv(ST = st.matrix.data, Ref = Ref, malProp = rep(0,  ncol(st.matrix.data)), malRef = NULL, mode = "deconvWithSC",  Unidentifiable = TRUE, coreNo = coreNo)

1.  SpaCET.deconvolution.matched.scRNAseq(SpaCET_obj = listSpaCET_scRNAseq[[i]],  sc_counts = as.matrix(Grout_Leader_data@assays$RNA@counts),  sc_annotation = Cell_annot[colnames(Grout_Leader_data@assays$RNA@counts),  ], sc_lineageTree = LineageTree, coreNo = detectCores())

How can I solve this ?

Mu code is

for (i in Patients) {
  SpotCoordinate <- GetTissueCoordinates(Plasticity_spatial.integrated, image = i)
  colnames(SpotCoordinate) <- c("Y", "X")
  spot_patient_i <- rownames(Plasticity_spatial.integrated@meta.data[Plasticity_spatial.integrated$Patient == i, ])
  SpotCoordinate_patient_i <- SpotCoordinate[spot_patient_i, ]

  counts_patient_i <- Plasticity_spatial.integrated@assays$Spatial@data[, spot_patient_i]

  listSpaCET_scRNAseq[[i]] <- create.SpaCET.object(counts =  counts_patient_i,
                                     spotCoordinates = SpotCoordinate_patient_i,
                                     platform = "Visium",
                                     imagePath = NA)

  listSpaCET_scRNAseq[[i]] <- SpaCET.deconvolution.matched.scRNAseq(SpaCET_obj = listSpaCET_scRNAseq[[i]], 
                                                                    sc_counts = as.matrix(Grout_Leader_data@assays$RNA@counts), 
                                                                    sc_annotation = Cell_annot[colnames(Grout_Leader_data@assays$RNA@counts), ], 
                                                                    sc_lineageTree = LineageTree, 
                                                                    coreNo=detectCores())

  }

Thanks !

beibeiru commented 1 year ago

Hi, Benjamin,

Would you please share these three objects with me, listSpaCET_scRNAseq, Grout_Leader_data and LineageTree?

Thanks.

Best, Beibei

beibeiru commented 1 year ago

I have sent a shared folder to your email @lri.fr. Does this work for you?

Beibei

BenjaminDEMAILLE commented 1 year ago

Sended by email

beibeiru commented 1 year ago

It takes one day to download your data from icloud.

Would you please upload it ot onedrive by the following link?

Beibei

BenjaminDEMAILLE commented 1 year ago

In Progress Can you delete it after ?

Le 6 févr. 2023 à 16:40, Beibei Ru @.***> a écrit :

It takes one day to download your data from icloud.

Would you please upload it ot onedrive by the following link? https://connecthkuhk-my.sharepoint.com/:f:/g/personal/bbru_connect_hku_hk/EuiCLs9VlDJCk33Khb88trkBNXbTS0wW8PxywwIsTE2dkg?e=yqVE4c

Beibei

— Reply to this email directly, view it on GitHub https://github.com/data2intelligence/SpaCET/issues/3#issuecomment-1419290100, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ6MVUEVL6ZBKSE73BWITWDWWELPVANCNFSM6AAAAAAUSU76SI. You are receiving this because you authored the thread.

beibeiru commented 1 year ago

Sure. BTW, you can find my email in this shared folder. Please drop me an email. Github hides your email in the previous message.

Beibei

beibeiru commented 1 year ago

Hi, Benjamin,

I load your shared data and found LineageTree is NULL, which is required by SpaCET.deconvolution.matched.scRNAseq.

I created a sample lineageTree below. Your code works now.

` i=1

LineageTree <- list( CAF=c("ADH1B+ CAF", "FAP+aSMA+ CAF", "FAP+ CAF", "MYH11+aSMA+ CAF"), cDC=c("cDC1", "cDC3"), venule=c("SELE- venule", "SELE+ venule"), Epithelials="Epithelials", MonoAndMac=c("CD14 mono","CD16 mono","MoMac_I","MoMac_II","MoMac_III","MoMac_IV") )

listSpaCET_scRNAseq[[i]] <- SpaCET.deconvolution.matched.scRNAseq( SpaCET_obj = listSpaCET_scRNAseq[[i]], sc_counts = as.matrix(Grout_Leader_data@assays$RNA@counts), sc_annotation = Cell_annot[colnames(Grout_Leader_data@assays$RNA@counts), ], sc_lineageTree = LineageTree, coreNo=10 )

[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."

listSpaCET_scRNAseq[[i]]@results$deconvolution$propMat[,1:3] AACACCTACTATCGAA-1_1 AACACGTGCATCGCAC-1_1 AACACTTGGCAAGGAA-1_1 CAF 7.933994e-02 8.388269e-02 7.791677e-02 cDC 4.279514e-02 3.056788e-02 6.546228e-02 venule 1.668174e-01 1.021401e-01 1.375143e-01 Epithelials 1.463830e-02 6.692166e-01 6.096133e-01 MonoAndMac 6.964092e-01 1.141927e-01 1.094934e-01 ADH1B+ CAF 1.789689e-02 5.402458e-03 1.910866e-02 FAP+aSMA+ CAF 2.012525e-07 7.174313e-03 4.052892e-08 FAP+ CAF 3.303265e-08 7.848801e-04 1.621470e-07 MYH11+aSMA+ CAF 6.144281e-02 7.052104e-02 5.878795e-02 cDC1 4.277525e-02 3.055939e-02 6.544243e-02 cDC3 5.866659e-10 1.158652e-09 2.430275e-08 SELE- venule 1.667974e-01 1.021201e-01 1.374961e-01 SELE+ venule 3.904214e-11 1.844960e-09 6.404675e-11 CD14 mono 7.897327e-09 7.765879e-04 1.716983e-09 CD16 mono 1.967896e-01 2.853063e-02 6.477837e-02 MoMac_I 1.646628e-01 1.943772e-02 7.747563e-07 MoMac_II 1.485670e-08 1.562344e-02 7.947284e-04 MoMac_III 1.323795e-01 2.229421e-02 4.162579e-02 MoMac_IV 2.025773e-01 2.753013e-02 2.293043e-03 `

Here, my suggestion is 1) reinstall SpaCET. 2) build a new lineage tree. The previous lineage tree I built is just an example, which includes a part of cell types from scRNA-seq data. Another tip is that you don't need to include all cell types from scRNA-seq data into the lineage tree. you can estimate which cell types exist in the ST data and use these cell types to build the lineage tree. The lineage tree should be organized by using a list, and the name of each element are major lineages while the value of elements are the corresponding sublineages (see the previous example). If a major lineage does not have any sublineages, the value of this major lineage should be itself. 3) I found your ST data from Visium. Thus, I strongly recommend you to read the data by using SpaCET_obj <- create.SpaCET.object.10X(visiumPath = visiumPath), which will import more information for visualization. The function requires one parameter "visiumPath". Please make sure that "visiumPath" points to the standard output folders of 10x SpaCET Ranger, which has both "filtered_feature_bc_matrix" and "spatial" folders.

Beibei

BenjaminDEMAILLE commented 1 year ago

I succeed to launch the run. Do you have an estimation of the duration ?

Le 6 févr. 2023 à 23:42, Beibei Ru @.***> a écrit :

Hi, Benjamin,

I load your shared data and found LineageTree is NULL, which is required by SpaCET.deconvolution.matched.scRNAseq.

I created a sample lineageTree below. Your code works now.

` i=1

LineageTree <- list( CAF=c("ADH1B+ CAF", "FAP+aSMA+ CAF", "FAP+ CAF", "MYH11+aSMA+ CAF"), cDC=c("cDC1", "cDC3"), venule=c("SELE- venule", "SELE+ venule"), Epithelials="Epithelials", MonoAndMac=c("CD14 mono","CD16 mono","MoMac_I","MoMac_II","MoMac_III","MoMac_IV") )

listSpaCET_scRNAseq[[i]] <- SpaCET.deconvolution.matched.scRNAseq( SpaCET_obj = listSpaCET_scRNAseq[[i]], sc_counts = @.**@.), sc_annotation = @.**@.), ], sc_lineageTree = LineageTree, coreNo=10 )

[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."

@.*** https://github.com/results$deconvolution$propMat[,1:3]

AACACCTACTATCGAA-1_1 AACACGTGCATCGCAC-1_1 AACACTTGGCAAGGAA-1_1

CAF 7.933994e-02 8.388269e-02 7.791677e-02

cDC 4.279514e-02 3.056788e-02 6.546228e-02

venule 1.668174e-01 1.021401e-01 1.375143e-01

Epithelials 1.463830e-02 6.692166e-01 6.096133e-01

MonoAndMac 6.964092e-01 1.141927e-01 1.094934e-01

ADH1B+ CAF 1.789689e-02 5.402458e-03 1.910866e-02

FAP+aSMA+ CAF 2.012525e-07 7.174313e-03 4.052892e-08

FAP+ CAF 3.303265e-08 7.848801e-04 1.621470e-07

MYH11+aSMA+ CAF 6.144281e-02 7.052104e-02 5.878795e-02

cDC1 4.277525e-02 3.055939e-02 6.544243e-02

cDC3 5.866659e-10 1.158652e-09 2.430275e-08

SELE- venule 1.667974e-01 1.021201e-01 1.374961e-01

SELE+ venule 3.904214e-11 1.844960e-09 6.404675e-11

CD14 mono 7.897327e-09 7.765879e-04 1.716983e-09

CD16 mono 1.967896e-01 2.853063e-02 6.477837e-02

MoMac_I 1.646628e-01 1.943772e-02 7.747563e-07

MoMac_II 1.485670e-08 1.562344e-02 7.947284e-04

MoMac_III 1.323795e-01 2.229421e-02 4.162579e-02

MoMac_IV 2.025773e-01 2.753013e-02 2.293043e-03

`

Here, my suggestion is

reinstall SpaCET. build a new lineage tree. The previous lineage tree I built is just an example, which includes a part of cell types from scRNA-seq data. Another tip is that you don't need to include all cell types from scRNA-seq data into the lineage tree. you can estimate which cell types exist in the ST data and use these cell types to build the lineage tree. The lineage tree should be organized by using a list, and the name of each element are major lineages while the value of elements are the corresponding sublineages (see the previous example). If a major lineage does not have any sublineages, the value of this major lineage should be itself. I found your ST data from Visium. Thus, I strongly recommend you to read the data by using SpaCET_obj <- create.SpaCET.object.10X(visiumPath = visiumPath), which will import more information for visualization. The function requires one parameter "visiumPath". Please make sure that "visiumPath" points to the standard output folders of 10x SpaCET Ranger, which has both "filtered_feature_bc_matrix" and "spatial" folders. Beibei

— Reply to this email directly, view it on GitHub https://github.com/data2intelligence/SpaCET/issues/3#issuecomment-1419882948, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ6MVUEKGFKUXPRWI7TMTZLWWF44JANCNFSM6AAAAAAUSU76SI. You are receiving this because you authored the thread.