我有一个基因表达数据矩阵,其中行是不同的基因,列是样本。
我有一个基因载体,我想从矩阵中筛选出来。使用基本语法很容易创建一个只有这些基因的矩阵:
expression_matrix[excluded_genes,]但我不知道如何做相反的事情,即从矩阵中删除这些基因,而不是选择它们。我到处寻找,但没有找到(或理解)什么东西来回答这个问题。
发布于 2018-01-08 13:23:17
希望这能有所帮助。
# Create data
X <- iris[1:4, ]
X
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#1 5.1 3.5 1.4 0.2 setosa
#2 4.9 3.0 1.4 0.2 setosa
#3 4.7 3.2 1.3 0.2 setosa
#4 4.6 3.1 1.5 0.2 setosa
# Remove the rows one and two
rows_to_remove <- c("1", "2")
X[!rownames(X) %in% rows_to_remove, ]
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#3 4.7 3.2 1.3 0.2 setosa
#4 4.6 3.1 1.5 0.2 setosahttps://stackoverflow.com/questions/48150721
复制相似问题