Thanks Gian.
Dear All,
I have a matrix contains the gene names at the first columns and the rest of columns in this matrix represent the gene expression in different tissues. My question is how to write a function or line in R to remove the rows that have expression less than specific value say 5.
3 answers
If you want to remove all the rows that never have expression of 5 or higher:
matrix[apply(matrix[,-1],1,function(X) length(X[X>=5])>0 ),]
If this answers your question please accept the answer
edgeR approach filters by counts per million (CPM), see for example page 11 of the user guide. y is a DGEList:
keep <- rowSums(cpm(y)>1) >= 2 y <- y[keep, , keep.lib.sizes=FALSE]
Have a look at the genefilter package in Bioconductor. In particular, note the kOverA() function.
I just need simple R line because I am using this file for testing something else (i.e easy line to do this regardless the first column if it is gene name oe anything else)
Log in to answer this question.