[datatable-help] Calculate correlation In R

akang adi2827 at gmail.com
Mon Feb 29 05:40:37 CET 2016


I have a total of 6 files. File1, File2, File3, File4 & File5 have the same
structure except for ID's. I want to

1.sum up the values in all rows like rowSums(file1)
2.Match the Id in File1-File5(Column1) to Id in File6 (Column2) and find the
correlation between the sum of rows from File1 and column3 of File6 so that
for 5 different files I have 5 different values and write it to a file. This
is what i tried but of course it doesnt work. Ill appreciate any help.TIA!

Geno<-read.table("data1", head=TRUE, row.names=1)
Pheno<-read.table("data1_p" )
rowSums(Geno)
cor(rowSums(Geno), Pheno$V3)


File1
  snp1 snp2 snp3
Id1 0.1 2.3 3.2
Id2 0.01 2.2 3.5
Id3 0.004 0.4 1

    File2
    snp1 snp2 snp3
    Id4 0.3 2.0 3.0
    Id5 0.1 2.02 3.05
    Id7 0.04 0.04 0.1

    File3
    snp1 snp2 snp3
    Id8 0.3 2.0 3.0
    Id9 0.1 2.02 3.05
    Id11 0.04 0.04 0.1

    File4
    snp1 snp2 snp3
    Id12 0.3 2.0 3.0
    Id13 0.1 2.02 3.05
    Id14 0.04 0.04 0.1

    File5
    snp1 snp2 snp3
    Id15 0.03 2.1 3.7
    Id16 0.01 2.05 3.01
    Id17 0.04 0.04 0.01

    File6 (No header)
    0 Id1 0.03 2.1 3.7
    2 Id2 0.01 2.05 3.01
    2 Id3 0.04 0.04 0.01
    0 Id4 0.03 2.1 3.7
    2 Id5 0.01 2.05 3.01
    2 Id6 0.04 0.04 0.01
    0 Id7 0.03 2.1 3.7
    2 Id8 0.01 2.05 3.01
    2 Id9 0.04 0.04 0.01
    0 Id10 0.03 2.1 3.7
    2 Id11 0.01 2.05 3.01
    2 Id12 0.04 0.04 0.01
    2 Id13 0.01 2.05 3.01
    2 Id14 0.04 0.04 0.01
    0 Id15 0.03 2.1 3.7
    2 Id16 0.01 2.05 3.01
    2 Id17 0.04 0.04 0.01



--
View this message in context: http://r.789695.n4.nabble.com/Calculate-correlation-In-R-tp4717984.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list