This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Summing data from 3 different parts of an R object at once

I have 3 replicate samples from a scRNA seq experiment; call them V1, V2, V3. I merged them into one large object "Object". When I merged them I appended the replicate name to the column barcodes, for example V2_ATGGAGTGGAT etc...

Object has a meta data column for cell cycle state located at Object$"Phase" . These are either "G1", "G2M", or "S; The Object also has cluster information that is located at Object$"seurat_clusters"

What I want to do is; for each replicate sum the number of cells in cluster x that are in cell phase "y"

So for example: For V1, sum the number of cells in G1 that are in cluster 1. Then I will repeat this for all clusters and cell phases and replicates to plot some data.

I can get the cluster and phase cell sum here: V.G1 <- sum(Object$"Phase" == "G1" & Object$"seurat_clusters" == 0)

But its not clear how to specify the replicate identifier for this operation?

Thanks!

r seurat scrna seq

1 answer

guys I got it!!!

X <- sum(Object$orig.ident == "V1" & Object$"Phase" == "G1" & 
          Object$"seurat_clusters" == 0)

Log in to answer this question.