Skip to content

Instantly share code, notes, and snippets.

@atlasbioinfo
Created August 19, 2020 02:28
Show Gist options
  • Save atlasbioinfo/366bb79c71740a6dbf8adeedf96e447c to your computer and use it in GitHub Desktop.
Save atlasbioinfo/366bb79c71740a6dbf8adeedf96e447c to your computer and use it in GitHub Desktop.
R语言批量t检验 t.test apply
> head(data,2)
A1 A2 A3 B1 B2 B3
TRINITY_DN100001_c0_g1 2.5 2.81 4.75 1.96 2.71 6.11
TRINITY_DN100002_c0_g1 0.0 0.00 0.00 0.00 0.00 40.45
> dim(data)
[1] 2000 6
pvalue=apply(data,1,function(x) t.test(x[1:3],x[4:6],paired = T)$p.value)
> head(pvalue,2)
TRINITY_DN100001_c0_g1 TRINITY_DN100002_c0_g1
0.7165794 0.4226497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment