Integrated Seurat object change name of the two conditions
0
0
Entering edit mode
9 weeks ago
camillab. ▴ 150

Hi,

I have a scRNAseq integrated seurat object composed by my control and my treatment. On this object I did all the analysis and I have all the plots needed (umap etc). Now it has been asked to use different names and instead of "control" and "treatment", I should use two different names (let's say "A" and "B" where A is my "control" and B is my treatment) for the plots showing the comparison of the two conditions (eg. violin plot).

So is there a way I can change "control" and "treatment" with "A" and "B" on my seurat object (maybe creating another column that I can refer to when I use for split.by) without have to re-do the integration from the beginning? or shall I just give up and modify the labelling in photoshop?

Thank you

Camilla

R integrated Seurat • 501 views
ADD COMMENT
0
Entering edit mode

Hi, See this prev. post where I contributed to, on accessing the meta data slot in a seurat object. There is more than one way.

ADD REPLY
0
Entering edit mode

thanks but my metadata looks different from yours. Will it work even there are not the same "structure"?

                           orig.ident nCount_RNA nFeature_RNA percent.mt  sample
Control_AAACCCAAGTACAGCG-1    Control       4133         1921   3.629325 Control
Control_AAACCCAAGTTAGTAG-1    Control       1234          700   6.320908 Control
Control_AAACCCACAAAGCAAT-1    Control       3361         1630  11.454924 Control
                           integrated_snn_res.0.2 seurat_clusters integrated_snn_res.0.3
Control_AAACCCAAGTACAGCG-1                      8              12                     12
Control_AAACCCAAGTTAGTAG-1                     12              11                     11
Control_AAACCCACAAAGCAAT-1                     14              15                     15
ADD REPLY
2
Entering edit mode

Yes, its similar structure. This snippet should add a new metadata column "sample.New" with what you want to do

Assuming a seurat obj. called "my.seuObj".

Check the distrib. of your labels in the pre-existing metadata column

table(my.seuObj@meta.data$sample)

Create a metadata column with dummy value

my.seuObj@meta.data$sample.New <- "placeholder"

Check

table(my.seuObj@meta.data$sample.New)

Change the value in "sample.New" metadata column w.r.t "sample"

my.seuObj@meta.data$sample.New[which(my.seuObj@meta.data$sample == "Control")] <- "A" my.seuObj@meta.data$sample.New[which(my.seuObj@meta.data$sample == "treatment")] <- "B"

Check

table(my.seuObj@meta.data$sample.New)

Check 2. This should be all "Control" value

my.seuObj@meta.data$sample[which(my.seuObj@meta.data$sample.New == "A")]

ADD REPLY
0
Entering edit mode

great! thank you very much!

ADD REPLY

Login before adding your answer.

Traffic: 1879 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6