Function for removing low expressed genes
3
2
Entering edit mode
9.0 years ago
M K ▴ 660

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.

R • 6.4k views
ADD COMMENT
4
Entering edit mode
9.0 years ago
5utr ▴ 370

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 ),]
ADD COMMENT
0
Entering edit mode

Thanks Gian.

ADD REPLY
0
Entering edit mode

If this answers your question please accept the answer

ADD REPLY
3
Entering edit mode
9.0 years ago
h.mon 35k

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]
ADD COMMENT
2
Entering edit mode
9.0 years ago

Have a look at the genefilter package in Bioconductor. In particular, note the kOverA() function.

ADD COMMENT
0
Entering edit mode

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)

ADD REPLY

Login before adding your answer.

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