0
對於文件夾中的所有文件miraligner
我想組合我的示例中顯示的列。我想將列c(「mir」,「seq」,「mism」,「add」,「t5」,「t3」)作爲輸出中的rownames並將"freq"
作爲來自各個輸入文件的列。 我不知道如何做到這一點的多個輸入文件從文件夾中合併多個不同長度的文件
> 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_file1 freq_file2 freq_file3
hsa-miR-122-5p_TGGAGTGTGATAATGGTGTTT_11TC_0_0_g 4 2 12
hsa-miR-30d-5p_TGTAAACATCCCCGACCGGAAGCT_17CT_0_0_CT 4 12 5
這是我的開始:
my.list <- lapply(X = my.file.list, FUN = function(x) {
read.table(x, colClasses = c("seq", "NULL", "NULL", "mir","NULL","NULL","mism","add","t5","t3","NULL","NULL","NULL","NULL","NULL"), sep = "\t")[,1]
})
是的,但是出錯了。我將刪除它 – user2300940
如果可以確保列在所有文件中相同,則以'input < - lapply(file.list,read.table,stringsASFactors = FALSE,<和其他適當的參數>)開頭。全集< - do.call(rbind,input)'。通過粘貼所需的列並將'cbind'-ing粘貼到'freq'上完成 –
我沒有收到最後一部分?如何將rbind轉換爲cbind格式? – user2300940