Q:

How to get the number of genes expressed in only one tissue

I would like to count the number of genes (rows):

expressed (value >0) in only one tissue (column) 
expressed (value >0) in only two tissues (columns)
expressed (value >0) in only 3 tissues (columns) 
expressed (value >0) in more than 3 tissues (> columns)

I have a table from RNA-Seq data and I have to get a table like:

number_of_tissue         nbr_expressed_genes
1 tissue         ->               3000
2 tissues       ->   500
3 tissues   -> 700
more than 3 -> 2500

is there any method with R or python to do this?

Thank you in advance 

A:

I believe the following will do what you want.
First the dataset in a copy&paste form.
Tissue1 <- c(0, 0, 1, 45)
Tissue2 <- c(0, 2, 4, 4)
Tissue3 <- c(0, 0, 5, 4)
Tissue4 <- c(1, 4, 90, 0)

rnaseq <- data.frame(Tissue1, Tissue2, Tissue3, Tissue4)
row.names(rnaseq) <- paste0("Gene", 1:4)

Now the code.
I start by computing how many values of Tissue* per row are greater than zero. Then The frequencies of those numbers with table. Then just transform this result into a data.frame.
res <- table(apply(rnaseq > 0, 1, sum))
res <- data.frame(number_of_tissue = paste(names(res), "tissues"),
                  nbr_expressed_genes = as.numeric(res))
row.names(res) <- NULL

res
#  number_of_tissue nbr_expressed_genes
#1        1 tissues                   1
#2        2 tissues                   1
#3        3 tissues                   1
#4        4 tissues                   1

