This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to merge miRDeep2 counts for DeSeq2 analysis?

Hi,

I am trying to identify DE miRNAs using small RNA-Seq data.

I ran miRDeep2 tools mapper.pl an also miRDeep2.pl scripts and got counts for my cases.

How can I merge count.cvs files of multiple cases for DE miRNA detection using DeSeq2 tool?

demirna mirdeep2 smallrna-seq

Please provide examples of the files.

Hi, thank you for your reply.

I have 15 miRNA counts csv files for normal group and also 16 miRNA counts csv files of cases and I want to merge them according to miRNAs in a file like:

#miRNA              ctrl1         ctrl2    case1         case2
hsa-let-7a-3p   read_count-ctrl1 read_count-ctrl2  read_count-case1 read_count-case2

And if the given miRNA is not exist in one of the cases write NA.

Example of file1:

#miRNA      read_count  precursor   total   seq seq(norm)
hsa-let-7a-3p   378 hsa-let-7a-1    378 378 85.03
hsa-let-7a-5p   101503  hsa-let-7a-2    101503  101503  22832.6
hsa-let-7a-2-3p 0   hsa-let-7a-2    0   0   0
hsa-let-7a-5p   101392  hsa-let-7a-3    101392  101392  22807.63
hsa-let-7a-3p   378 hsa-let-7a-3    378 378 85.03
hsa-let-7b-5p   1611    hsa-let-7b  1611    1611    362.39
hsa-let-7b-3p   18  hsa-let-7b  18  18  4.05
hsa-let-7c-5p   6064    hsa-let-7c  6064    6064    1364.07
hsa-let-7c-3p   0   hsa-let-7c  0   0   0
hsa-let-7d-5p   5379    hsa-let-7d  5379    5379    1209.98
hsa-let-7d-3p   13094   hsa-let-7d  13094   13094   2945.43

Example of file2:

#miRNA     read_count   precursor   total   seq seq(norm)
hsa-let-7a-3p   197 hsa-let-7a-1    197 197 89.93
hsa-let-7a-5p   59277   hsa-let-7a-2    59277   59277   27060.2
hsa-let-7a-2-3p 0   hsa-let-7a-2    0   0   0
hsa-let-7a-5p   59249   hsa-let-7a-3    59249   59249   27047.42
hsa-let-7a-3p   197 hsa-let-7a-3    197 197 89.93
hsa-let-7b-5p   861 hsa-let-7b  861 861 393.05
hsa-let-7b-3p   1   hsa-let-7b  1   1   0.46
hsa-let-7c-5p   4612    hsa-let-7c  4612    4612    2105.4
hsa-let-7c-3p   0   hsa-let-7c  0   0   0
hsa-let-7d-5p   3753    hsa-let-7d  3753    3753    1713.26
hsa-let-7d-3p   8019    hsa-let-7d  8019    8019    3660.71
hsa-let-7e-5p   370 hsa-let-7e  370 370 168.91
hsa-let-7e-3p   0   hsa-let-7e  0   0   0
hsa-let-7f-5p   140096  hsa-let-7f-1    140096  140096  63954.42
hsa-let-7f-1-3p 13  hsa-let-7f-1    13  13  5.93
hsa-let-7f-5p   152133  hsa-let-7f-2    152133  152133  69449.36
hsa-let-7f-2-3p 5   hsa-let-7f-2    5   5   2.28
hsa-let-7g-5p   44707   hsa-let-7g  44707   44707   20408.94
hsa-let-7g-3p   0   hsa-let-7g  0   0   0

1 answer

Read the files into R, extract miRNA and read_count column and then merge them, something like:

#/ example for files already loaded into R and filtered for miRNA and read_count:
file1 <- data.frame(miRNA=c("miRNA1", "miRNA2"), read_count=c(0, 2))
file2 <- data.frame(miRNA=c("miRNA1", "miRNA2"), read_count=c(4, 3))
file3 <- data.frame(miRNA=c("miRNA1", "miRNA2"), read_count=c(1, 9))
file4 <- data.frame(miRNA=c("miRNA1", "miRNA2"), read_count=c(3, 20))

#/ use merge and reduce to merge a list of files (list can be arbitrarily long),
#/ see also: https://stackoverflow.com/questions/8091303/simultaneously-merge-multiple-data-frames-in-a-list
count_matrix <- 
  Reduce(function(dtf1, dtf2) merge(dtf1, dtf2, by = "miRNA", all.x = TRUE),
         list(file1,file2,file3,file4))

#/ set some proper colnames, e.g. based on the file name:
colnames(count_matrix) <- c(...)

Thank you so much!

The codes you send working for 2 or 3 files but now I am dealing with memory error in R :(

I tried to set memory limit but still getting error 1.7 GB cannot allocate.

Is there any way to do it using terminal?

Log in to answer this question.