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(...)
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:
And if the given miRNA is not exist in one of the cases write NA.
Example of file1:
Example of file2: