I have a matrix containing gene names and sample numbers. Each row is a logical vector indicating the samples in which a gene was detected. Genes must appear in a minimum of 4 samples out of 8 to make it this far (still be in the matrix). i.e., all genes in this matrix appear in 4 or more samples.
Sample1 Sample2 Sample3 Sample4 Sample5 Sample6 Sample7 Sample8
gene1 TRUE FALSE TRUE TRUE TRUE FALSE FALSE FALSE
gene2 FALSE TRUE FALSE TRUE FALSE TRUE TRUE FALSE
gene3 TRUE TRUE FALSE TRUE FALSE TRUE TRUE FALSE
gene4 FALSE FALSE TRUE FALSE TRUE FALSE FALSE TRUE
gene5 TRUE TRUE TRUE TRUE TRUE FALSE TRUE TRUE
gene6 FALSE FALSE TRUE FALSE FALSE TRUE TRUE TRUE
gene7 TRUE TRUE FALSE FALSE TRUE TRUE FALSE FALSE
gene8 TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE
I could also say I have the list of samples for which the latter was expressed, such as:
> gene1
[1] "Sample1" "Sample3" "Sample4" "Sample5"
How can I obtain the largest set of genes (rows) that belong to a common set of 4 samples (columns)?
Edit: This question stems from trying to recreate this:
Outlier analysis is based on the assumption that samples (cells) of the same type also have a set of commonly-expressed genes.
The outlier algorithm iteratively trims the low-expressing genes in an expression file until 95% of the genes that remain are expressed above the Limit of Detection (LoD) value that you set for half of the samples.
The assumption is that the set of samples contains less than 50% outliers. This means that subsequent calculations will only include the half of the samples that have the highest expression for the trimmed gene list.
The trimmed gene list represents genes that are present above the LoD in at least half the samples or the most evenly expressed genes—though they might not be the highest or lowest in their expression value.
For the 50% of the samples that remain, a distribution is calculated that represents their combined expression values for the gene list defined above. For this distribution, the median represents the 50th percentile expression value for the set of data.