Question: How to filter out low read counts
0
4 weeks ago by
annkolman780 wrote:

Hi,

I have my data in a SummarizedExperiment format. I would like to filter out reads that have less than 1 read count (exp_count<1)

data

  data class: RangedSummarizedExperiment
dim: 56756 100
assays(10): exp_count TPM ...
FPKM
FPKM_CO
rownames(57736): ENSG00000000003
ENSG00000000005 ... ENSG00000273492
ENSG00000273493
rowData names(9): gene hgncl ...
colnames(100): 1 1 ...
99 100
colData names(13): ID SAMPLE


I have tried:

data_matrix <- data@assays[[1]]
data_filtered <- data_matrix[rowSums(count(data_matrix))>1,]


but got an error:

Error in count(data_matrix) :
Argument 'x' must be a vector: numeric


and

data_filtered <- data[rowSums(count(data@assays[[1]]))>1,]

Error in count(data@assays[[1]]) :
Argument 'x' must be a vector: numeric


Thank you.

summarizedexperiment • 80 views
modified 4 weeks ago by Martin Morgan ♦♦ 24k • written 4 weeks ago by annkolman780

Please NEVER use direct slot access @ and instead use accessors, assay() or assays(data)[[1]].

ADD REPLYlink written 4 weeks ago by Martin Morgan ♦♦ 24k

Hi,

Thank you for your reply. I have modified it. What is the reason? But, unfortunatelly it didn't solve the problem.

Thank you

'Accessors' define how the object is to be manipulated by the user, allowing the developer to chose representations that are efficient for them. For instance, in the Biostrings package

> dna = Biostrings::DNAStringSet("AA")
> dna@<tab>
dna@elementType     dna@pool


there is no obvious relationship between operations the user might like to perform and the slots used by the developer to represent the data.

ADD REPLYlink written 4 weeks ago by Martin Morgan ♦♦ 24k
Answer: How to filter out low read counts
1
4 weeks ago by
Martin Morgan ♦♦ 24k
United States
Martin Morgan ♦♦ 24k wrote:

Note that assays(data)[["exp_count"]] is a matrix, so perhaps you are interested in

keep <- rowSums(assays(data)[["exp_count"]]) > 1
data_filtered <- data[keep,]

ADD COMMENTlink modified 4 weeks ago • written 4 weeks ago by Martin Morgan ♦♦ 24k

Thank you for your answer, I run it and got this error:

Error in assay(data)[["exp_count"]] :
subscript out of bounds


updated assay() --> assays()

ADD REPLYlink written 4 weeks ago by Martin Morgan ♦♦ 24k

It is working thank you very much!