对于文件夹miraligner
中的所有文件,我想组合列,如我的示例所示。我想结合列c(" mir"," seq"," mism"," add"," t5& #34;," t3")以及在输出中添加"freq"
作为第2列。
我不知道如何为多个输入文件执行此操作
> setwd("~/miraligner/")
> file_list <- list.files(pattern = "*.mirna")
> head(file_list)
[1] "1_JH_F12_S41.mirna" "107_MAE_E7_S11.mirna" "108_IME_A8_S23.mirna" "109_GW_B11_S27.mirna" "111_PH_H1_S77.mirna"
[6] "116_TH_E6_S10.mirna"
> head(1_JH_F12_S41.mirna)
seq name freq mir start end mism add t5 t3 s5 s3 DB
1 TGGAGTGTGATAATGGTGTTT seq_100003_x4 4 hsa-miR-122-5p 15 35 11TC 0 0 g GCTGTGGA TTTGTGTC miRNA
2 TGTAAACATCCCCGACCGGAAGCT seq_100045_x4 4 hsa-miR-30d-5p 6 29 17CT 0 0 CT TTGTTGTA GAAGCTGT miRNA
3 CTAGACTGAAGCTCCTTGAAAA seq_100048_x4 4 hsa-miR-151a-3p 47 65 0 I-AAA 0 gg CCTACTAG GAGGACAG miRNA
4 AGGCGGAGACTTGGGCAATTGC seq_100059_x4 4 hsa-miR-25-5p 14 35 0 0 0 C TGAGAGGC ATTGCTGG miRNA
5 AAACCGTTACCATTACTGAAT seq_100067_x4 4 hsa-miR-451a 17 35 0 I-AT 0 gtt AAGGAAAC AGTTTAGT miRNA
6 TGAGGTAGTAGCTTGTGCTGTT seq_10007_x24 24 hsa-let-7i-5p 6 27 12CT 0 0 0 TGGCTGAG TGTTGGTC miRNA
precursor ambiguity
1 hsa-mir-122 1
2 hsa-mir-30d 1
3 hsa-mir-151a 1
4 hsa-mir-25 1
5 hsa-mir-451a 1
6 hsa-let-7i 1
输出
ID freq
hsa-miR-122-5p_TGGAGTGTGATAATGGTGTTT_11TC_0_0_g 4
hsa-miR-30d-5p_TGTAAACATCCCCGACCGGAAGCT_17CT_0_0_CT 4
答案 0 :(得分:1)
file_list <- list.files(pattern = "*.mirna")
df = data.frame()
for (i in file_list) {
df <- rbind(df,read.csv(paste(i))) #combines all files into a single dataframe
}
df$merged <- paste(df$seq,df$mism,df$add,df$t5,df$t3,sep = "_")
df <- data.frame(ID = df$merged,freq = df$freq)