Entering edit mode
7.7 years ago
User000
▴
710
Hello, I have a gene count matrix with 1 condition only. I have made log2(raw_count+1) with DESeq2, but when I filter off genes with zero expression my gene names disappear. How to fix this so that at the end I have my gene names and log2 values?
raw_count <- read.csv("gene_count_matrix.csv", header = TRUE, row.names = 1)
# Remove all gene which has 0 value in all sample
all <- apply(raw_count, 1, function(x) all(x==0))
newdata <- raw_count[!all,]
write.csv(newdata, file = "filtered_matrix.csv")
final_count <- read.csv("filtered_matrix.csv", header=TRUE, row.names = 1)
this works, thank you! strangely, when I have many conditions this does not happen, do you know why? thank you again
Because if you have only one column in your matrix/dataframe, the default behaviour of R is to convert it into a vector. Edit : more info in the R help :