This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract rows with rownames from seurat objects in R?

Hello,

I have 4 Seurat Objects and i am trying to get common genes(row.names) from them, with the rows (All values associated with that). I know with intersect i can fid common genes but extracting with their values is tricky part. Any suggestions Appreciated.

Newfunction<- function(A,B,C,D) {
  Matrix_1 <- (intersect(row.names(A),row.names(B)))
  Matrix_2 <- intersect(row.names(C),row.names(D))
  Combined_matrix <- intersect(Matrix_1,Matrix_2)
  return(Combined_matrix)
}
Newfunction (Healthy_1, Healthy_2, Healthy_3, Aggr_data)

Best KD

r seurat

1 answer

Thanks Max. I followed exactly same method to get my results.

total.genes <- list(rownames(Healthy_1),
                    rownames(Healthy_2),
                    rownames(Healthy_3),
                    rownames(Aggr_data))

common.genes <- Reduce(f = intersect, x = total.genes)

For subest merged_frame is my dataframe here

subset <- Merged_frame[common.genes,]

Log in to answer this question.