我有看起来像这样的文件:
$ head -n3 *.full.tsv
==> XOX.full.tsv <==
Probe Index Gene Symbol log2(FC) pval CV
1427747_a_at Lcn2 5.205 1.098e-02 0.455
1449326_x_at Saa2 4.585 3.614e-04 0.788
==> QUX.full.tsv <==
Probe Index Gene Symbol log2(FC) pval CV
1450783_at Ifit1 5.820 2.564e-02 0.256
1421008_at Rsad2 5.631 4.781e-02 0.292
==> FOO.full.tsv <==
Probe Index Gene Symbol log2(FC) pval CV
1434719_at A2m 7.823 1.753e-02 0.415
1427747_a_at Lcn2 6.696 4.255e-03 0.455
==> BAR.full.tsv <==
Probe Index Gene Symbol log2(FC) pval CV
1449647_at --- 2.227 5.194e-02 0.744
1455889_at Far2 2.210 7.342e-02 0.406
然后我想要做的是 glob 文件并将它们组合成单个融化的数据框,如下所示:
Filename Probe Index Gene Symbol log2(FC) pval CV
XOX 1427747_a_at Lcn2 5.205 1.098e-02 0.455
XOX 1449326_x_at Saa2 4.585 3.614e-04 0.788
QUX 1450783_at Ifit1 5.820 2.564e-02 0.256
QUX 1421008_at Rsad2 5.631 4.781e-02 0.292
FOO 1434719_at A2m 7.823 1.753e-02 0.415
FOO 1427747_a_at Lcn2 6.696 4.255e-03 0.455
BAR 1449647_at --- 2.227 5.194e-02 0.744
BAR 1455889_at Far2 2.210 7.342e-02 0.406
我试过了,但没有给出我想要的
infiles <- paste("./","*.*.*.full.tsv",sep="")
dataFiles <- lapply(Sys.glob(infiles), read.table,sep="\t",header=TRUE,check.names=FALSE )
tmp <- do.call(rbind,dataFiles)
head(tmp)
我仍然无法捕获文件名的地方:
Probe Index Gene Symbol log2(FC) pval CV
1 1427747_a_at Lcn2 5.205 1.098e-02 0.455
2 1449326_x_at Saa2 4.585 3.614e-04 0.788
我应该怎么做?