Extract rows with rownames from seurat objects in R?
1
0
Entering edit mode
4.1 years ago
patel.kru ▴ 10

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 • 4.0k views
ADD COMMENT
0
Entering edit mode
ADD REPLY
1
Entering edit mode
4.1 years ago
patel.kru ▴ 10

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,]
ADD COMMENT

Login before adding your answer.

Traffic: 1957 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