Я смотрю на данные, которые не все имеют одинаковые значения для имен строк.Некоторые из этих генов не экспрессируются в других наборах данных.Как я могу использовать lower (intersect, list (a, b, c)), чтобы выбрать общие имена строк вместе с соответствующими значениями столбцов?
Я пытался использовать
Reduce(intersect, list(data.UT, c_data.MT, c_data.HT))
, но это будет просто выводить общие имена строк.
e2.Matrix <- matrix(nrow = 130, ncol = 15)
e3.Matrix <- matrix(nrow = 339, ncol = 15)
# read in the datasets
df.UT<- read.csv("05.08.19.UT_AdultVInfant.wadjp.csv", header= TRUE,
row.names= NULL)
# change header to TRUE if comparing condition bound by columns
# change header to FALSE if comparing condition bound by rows
df.MT<- read.csv("05.15.19.MT_AdultVInfant.wadjp.csv", header= TRUE,
row.names= NULL)
# change header to TRUE if comparing condition bound by columns
# change header to FALSE if comparing condition bound by rows
df.HT<- read.csv("05.15.19.HT_AdultVInfant.wadjp.csv", header= TRUE,
row.names= NULL)
# convert dataframes to matrices so we can combine them with the empty matrices
data.matrix(df.UT[,2:15])
data.matrix(df.MT[,2:15])
data.matrix(df.HT[,2:15])
data.UT <- cbind(data.matrix(df.UT$gene), data.matrix(df.UT[,2:15]))
data.MT <- cbind(data.matrix(df.MT$gene), data.matrix(df.MT[,2:15]))
data.HT <- cbind(data.matrix(df.HT$gene), data.matrix(df.HT[,2:15]))
# data,UT is the laregest matrix so it does not extra rows
# bind the smaller matrices so all are same length
c_data.MT <- rbind(data.MT, e2.Matrix)
c_data.HT <- rbind(data.HT, e3.Matrix)
# this script will select only the gene that are shared amongst the 3 condition
# view the new data frame
# export the data frame to a text editor to make list of genes to select for in filter
View(Reduce(intersect, list(data.UT, c_data.MT, c_data.HT)))
Это вывод, который я получаю
[1] "AC009234.1" "ACSL5" "ADAMTS15" "ALDH3A1" "ANKRD45"
"CES1P1" "CES1P2"
[8] "COL4A1" "COL4A2" "COL5A2" "CYP2A6" "CYP2A7"
"CYP2A7P1" "CYP2B6"
[15] "CYP2C18" "MRC2" "SCGB3A1" "0"
, но должны быть соответствующие значения для столбцов