R语言在读取数据 例如read.table 添加check.names=F 参数可以保证数据种特殊的字符正常读取:
如数据表头 “-”被认为是“."
> A=read.table("F:/test/WGCNA/data/fpkm/All.DEG_final_3000.xls",sep="\t",check.names=T,header=T)
> head(A,2)
ID CK.WT.1 CK.WT.2 CK.WT.3 CK.tdr1.1 CK.tdr1.2 CK.tdr1.3 NaWT.1 NaWT.2 NaWT.3
1 AT1G01010 3.74149 7.3618 5.81734 5.71131 7.97054 10.37620 6.29949 5.55062 5.84779
2 AT1G01030 5.23528 2.7707 2.66859 3.22632 1.32105 1.96726 2.40259 3.23077 4.80378
Natdr1.1 Natdr1.2 Natdr1.3 Na.WT.1 Na.WT.2 Na.WT.3 Na.tdr1.1 Na.tdr1.2 Na.tdr1.3
1 15.58810 14.76360 17.74670 9.84943 7.97949 6.841060 13.29120 25.37000 19.59940
2 2.04301 2.29524 1.95286 1.83377 1.70757 0.809564 3.23172 1.80478 2.06044
SWT.1 SWT.2 SWT.3 Stdr1.1 Stdr1.2 Stdr1.3
1 4.96687 5.53349 3.18816 6.93650 7.88402 11.25040
2 8.49256 2.65564 2.25570 4.35298 4.52147 7.11351
> A=read.table("F:/test/WGCNA/data/fpkm/All.DEG_final_3000.xls",sep="\t",check.names=F,header=T)
> head(A,2)
ID CK-WT-1 CK-WT-2 CK-WT-3 CK-tdr1-1 CK-tdr1-2 CK-tdr1-3 NaWT-1 NaWT-2 NaWT-3
1 AT1G01010 3.74149 7.3618 5.81734 5.71131 7.97054 10.37620 6.29949 5.55062 5.84779
2 AT1G01030 5.23528 2.7707 2.66859 3.22632 1.32105 1.96726 2.40259 3.23077 4.80378
Natdr1-1 Natdr1-2 Natdr1-3 Na-WT-1 Na-WT-2 Na-WT-3 Na-tdr1-1 Na-tdr1-2 Na-tdr1-3
1 15.58810 14.76360 17.74670 9.84943 7.97949 6.841060 13.29120 25.37000 19.59940
2 2.04301 2.29524 1.95286 1.83377 1.70757 0.809564 3.23172 1.80478 2.06044
SWT-1 SWT-2 SWT-3 Stdr1-1 Stdr1-2 Stdr1-3
1 4.96687 5.53349 3.18816 6.93650 7.88402 11.25040
2 8.49256 2.65564 2.25570 4.35298 4.52147 7.11351
data.frame() 函数在进行数据框组合时也存在 字符变化,需要设置check.names=F
数据框:
> A1=A[,1:12]
> head(A1,2)
ID CK-WT-1 CK-WT-2 CK-WT-3 CK-tdr1-1 CK-tdr1-2 CK-tdr1-3 NaWT-1 NaWT-2 NaWT-3
1 AT1G01010 3.74149 7.3618 5.81734 5.71131 7.97054 10.37620 6.29949 5.55062 5.84779
2 AT1G01030 5.23528 2.7707 2.66859 3.22632 1.32105 1.96726 2.40259 3.23077 4.80378
Natdr1-1 Natdr1-2
1 15.58810 14.76360
2 2.04301 2.29524
> A2=A[,13:24]
> head(A2,2)
Natdr1-3 Na-WT-1 Na-WT-2 Na-WT-3 Na-tdr1-1 Na-tdr1-2 Na-tdr1-3 SWT-1 SWT-2 SWT-3
1 17.74670 9.84943 7.97949 6.841060 13.29120 25.37000 19.59940 4.96687 5.53349 3.18816
2 1.95286 1.83377 1.70757 0.809564 3.23172 1.80478 2.06044 8.49256 2.65564 2.25570
Stdr1-1 Stdr1-2
1 6.93650 7.88402
2 4.35298 4.52147
组合:
> B=data.frame(A1,A2)
> head(B,2)
ID CK.WT.1 CK.WT.2 CK.WT.3 CK.tdr1.1 CK.tdr1.2 CK.tdr1.3 NaWT.1 NaWT.2 NaWT.3
1 AT1G01010 3.74149 7.3618 5.81734 5.71131 7.97054 10.37620 6.29949 5.55062 5.84779
2 AT1G01030 5.23528 2.7707 2.66859 3.22632 1.32105 1.96726 2.40259 3.23077 4.80378
Natdr1.1 Natdr1.2 Natdr1.3 Na.WT.1 Na.WT.2 Na.WT.3 Na.tdr1.1 Na.tdr1.2 Na.tdr1.3
1 15.58810 14.76360 17.74670 9.84943 7.97949 6.841060 13.29120 25.37000 19.59940
2 2.04301 2.29524 1.95286 1.83377 1.70757 0.809564 3.23172 1.80478 2.06044
SWT.1 SWT.2 SWT.3 Stdr1.1 Stdr1.2
1 4.96687 5.53349 3.18816 6.93650 7.88402
2 8.49256 2.65564 2.25570 4.35298 4.52147
> B=data.frame(A1,A2,check.names=F)
> head(B,2)
ID CK-WT-1 CK-WT-2 CK-WT-3 CK-tdr1-1 CK-tdr1-2 CK-tdr1-3 NaWT-1 NaWT-2 NaWT-3
1 AT1G01010 3.74149 7.3618 5.81734 5.71131 7.97054 10.37620 6.29949 5.55062 5.84779
2 AT1G01030 5.23528 2.7707 2.66859 3.22632 1.32105 1.96726 2.40259 3.23077 4.80378
Natdr1-1 Natdr1-2 Natdr1-3 Na-WT-1 Na-WT-2 Na-WT-3 Na-tdr1-1 Na-tdr1-2 Na-tdr1-3
1 15.58810 14.76360 17.74670 9.84943 7.97949 6.841060 13.29120 25.37000 19.59940
2 2.04301 2.29524 1.95286 1.83377 1.70757 0.809564 3.23172 1.80478 2.06044
SWT-1 SWT-2 SWT-3 Stdr1-1 Stdr1-2
1 4.96687 5.53349 3.18816 6.93650 7.88402
2 8.49256 2.65564 2.25570 4.35298 4.52147
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!