This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to to add patient information to seurate metadata.

I am analyzing some single-cell data and I have the output of the GSE131907 (normalized log2TPM_matrix). I am trying to retrieve the samples ID stored in the .csv file and I want to add them to the Seurat object to be able to use group.by parameter downstream but I keep having problems with that.

GSE131907.genes<- readRDS("Raw/GSE131907_Lung_Cancer_normalized_log2TPM_matrix.rds/GSE131907_Lung_Cancer_normalized_log2TPM_matrix.rds")

dim(GSE131907.genes)
head(GSE131907.genes)
head(x = rownames(x = GSE131907.genes))
head(x = colnames(x = GSE131907.genes))

GSE131907.seurat <- Seurat::CreateSeuratObject(counts = GSE131907.genes, min.cells = 10, min.features = 200)

   # add metadata
sample_metadata <- read.csv(file = "cellinfor.csv")
rownames(sample_metadata) <- sample_metadata$UniqueCell_ID
cell_metadata <- sample_metadata[GSE131907.seurat $orig.ident,]
for(meta in names(cell_metadata)){
  cur_seurat[[meta]] <- cell_metadata[[meta]]

However, if I try to use the table(GSE131907.seurat@meta.data$patientid) doesn't seem to be added to the metadata. I would appreciate any suggestion! Thanks!

metadata cellid

basically, I would like to add columname such as (Patient id,Samples, Tissue origins, Histology, Smoking, Pathology, EGFR, Stages) from the cell info file to match the cellID) Manually adding so hassle

1 answer

let's start by fixing the typo: rownames(cellinfro)<- should read rownames(cellinfo)<-

this is not the main problem. Anway Thanks

Log in to answer this question.