BodenmillerGroup / IMCDataAnalysis

R based workflow for multiplexed imaging data
https://bodenmillergroup.github.io/IMCDataAnalysis/
MIT License
29 stars 12 forks source link

Problem with concatenation #93

Closed GiCarlu closed 9 months ago

GiCarlu commented 9 months ago

When I do the step 9.3.3 I receive this error:

concat_spe <- do.call("cbind", spes) 'sample_id's are duplicated across 'SpatialExperiment' objects to cbind; appending sample indices. Error in .aggregate_and_align_all_colnames(all_colnames, strict.colnames = strict.colnames) : the DFrame objects to combine must have the same column names

But the name that I give to the file .rds are the same as they do in the pipeline (for example "Tumor_1.rds, Tumor_2.rds, etc.)

How can I solve this error?

Thanks in advance

SchulzDan commented 9 months ago

Hi @GiCarlu

I believe that potentially you changed some namings of the objects during the labelling process. As the error message says: "DFrame objects to combine must have the same colnames" it seems that the colnames of the colData have changed. Have you modified the data during the labelling process?

Anyway, you could try this before concatenation to only keep relevant information in the spes.

spes <- lapply(spes,function(x) {
  colData(x) <- colData(x)[,c("sample_id", "ObjectNumber","cytomapper_CellLabel")]
  return(x)
})

Hope that works. Best, Daniel

GiCarlu commented 9 months ago

Hi,

with the part of code that you advice me working, but now the problem is that when I create all the gate and I rename them as "Tumor.1", "Tumor.2" etc. the table that create not merge my file .rds

table(spe$cell_labels, spe$patient_id)

        G18231 G18232

Tumor.1 31 0 Tumor.10 13 0 Tumor.11 32 0 Tumor.12 0 2878 Tumor.13 0 1709 Tumor.14 0 2674 Tumor.2 1072 0 Tumor.3 12 0 Tumor.4 8 0 Tumor.5 11 0 Tumor.6 109 0 Tumor.7 1115 0 Tumor.8 901 0 Tumor.9 6 0 unlabeled 26803 1647

how can I solve this problem? Because I want all the tumor gated together.

thank you so much