I have a data frame of raw read counts, genes in rows and samples in columns
> dput(head(oc))
structure(list(sample1 = c(13L, 0L, 1L, 42L, 15L, 1137L), sample2 = c(21L,
2L, 20L, 51L, 5L, 203L), sample3 = c(25L, 2L, 6L, 71L, 36L, 1346L
), sample4 = c(59L, 3L, 8L, 58L, 42L, 3428L), sample5 = c(19L,
4L, 8L, 52L, 1L, 201L)), row.names = c("WASH7P", "MIR6859-1",
"CICP27", "WASH9P", "MTND1P23", "MTND2P28"), class = "data.frame")
>
> head(oc)
sample1 sample2 sample3 sample4 sample5
WASH7P 13 21 25 59 19
MIR6859-1 0 2 2 3 4
CICP27 1 20 6 8 8
WASH9P 42 51 71 58 52
MTND1P23 15 5 36 42 1
MTND2P28 1137 203 1346 3428 201
>
I just want to keep genes with at least 10 reads in each sample, I mean even if a gene has less than 10 reads in one sample and the rest of four samples have 10 reads, this gene should be removed. For instance here the second, third and fifth rows should be removed
I tied this but all I obtained zero
> df=t(oc)
> cutoff <- 10
>
> # encode the data based on the cutoff
> df[df >= cutoff] <- 1
> df[df < cutoff] <- 0
> View(df)
> rowSums(df)
sample1 sample2 sample3 sample4 sample5
0 0 0 0 0
>
> apply(df >= 5, 1, sum)
sample1 sample2 sample3 sample4 sample5
0 0 0 0 0
> apply(df >= 1, 1, sum)
sample1 sample2 sample3 sample4 sample5
0 0 0 0 0
>
Any suggestion please?