[R] spearman correlation and p-value as a matrix
arun
smartpink111 at yahoo.com
Thu Feb 14 15:12:21 CET 2013
Dear Ozgul,
You could use ?table() or ?count from library(plyr)
I assume that you wanted to count only from the first column.
data2<- read.csv("cor3.csv",sep="\t",stringsAsFactors=FALSE)
res1<-as.data.frame(table(data2[,1]))
res2<-count(data2[,1])
colnames(res1)<- colnames(res2)
identical(res1,res2)
#[1] TRUE
A.K.
----- Original Message -----
From: Ozgul Inceoglu <Ozgul.Inceoglu at ulb.ac.be>
To: arun <smartpink111 at yahoo.com>
Cc:
Sent: Thursday, February 14, 2013 6:17 AM
Subject: re:Re: [R] spearman correlation and p-value as a matrix
Dear Arun,
I bothered you this week alot, but it seems like that you know your way in R very well. I would appreciate if you can help me with one more thing. I have 2 data files. One is the average value of each OTU. Second file has the correlation between each OTU, but I would like to plot how many times a OTU correlated against its relative abundance. As you see in data2 file, OTU0001 have around 53 correlations. Is it possible to count that in R with a script? Because my table is too long to count by eye. I saw some script to count numeric values but the column one is text. And I will plot data1$average data2$number of occurence (e.g.53)
Thank you very much!
Ö
data1
name average
Otu0001 0.059348357
Otu0002 0.030641714
Otu0003 0.011322821
Otu0004 0.080583357
Otu0005 0.022009357
data2
Var1 Var2 Freq
Otu0001 Otu00002 0.50308393782931
Otu0001 Otu00003 0.835976014100782
Otu0001 Otu00021 0.913558114482734
Otu0001 Otu00027 0.905670284922677
Otu0001 Otu00046 0.581582392764371
Otu0001 Otu00047 0.867801609030349
Otu0001 Otu00057 0.678979275105813
Otu0001 Otu00066 0.665704636891185
Otu0001 Otu00083 0.573139564297305
Otu0001 Otu00084 0.654793315615399
Otu0001 Otu00114 0.545574076996571
Otu0001 Otu00133 0.860299149983324
Otu0001 Otu00149 0.565446769229162
Otu0001 Otu00154 0.651905880329591
Otu0001 Otu00165 0.588000078791058
Otu0001 Otu00199 0.636977290142002
Otu0001 Otu00242 0.733670340504493
Otu0001 Otu00265 0.56572800115343
Otu0001 Otu00271 0.52274494018959
Otu0001 Otu00290 0.565784159732485
Otu0001 Otu00498 0.69700879002542
Otu0001 Otu00543 0.688857846593924
Otu0001 Otu00619 0.568561351623871
Otu0001 Otu00646 0.710973182296609
Otu0001 Otu00915 0.67389659584841
Otu0001 Otu00949 0.658902464342605
Otu0001 Otu01035 0.730329506746752
Otu0001 Otu01327 0.680119572628299
Otu0001 Otu01631 0.537404605465553
Otu0001 Otu01638 0.624999817224687
Otu0001 Otu01642 0.572231019174333
Otu0001 Otu01649 0.551184564584919
Otu0001 Otu01651 0.600983572760604
Otu0001 Otu01655 0.522736661453493
Otu0001 Otu01657 0.756955802070428
Otu0001 Otu01669 0.540295474451908
Otu0001 Otu01678 0.628300552686822
Otu0001 Otu01691 0.527963252499515
Otu0001 Otu01711 0.58532121170348
Otu0001 Otu01722 0.521754446131501
Otu0001 Otu01729 0.626564045909824
Otu0001 Otu01745 0.685208099879848
Otu0001 Otu01748 0.533461010235307
Otu0001 Otu01776 0.708721334709103
Otu0001 Otu01795 0.774684206920168
Otu0001 Otu01802 0.515477574463339
Otu0001 Otu01828 0.595278507951326
Otu0001 Otu01836 0.521155845049491
Otu0001 Otu01856 0.597043163472699
Otu0001 Otu01897 0.510475231901277
Otu0001 Otu01946 0.514243028056249
Otu0001 Otu02289 0.547405617805684
Otu0002 Otu00003 0.694555195101993
Otu0002 Otu00021 0.851014016127985
Otu0002 Otu00027 0.846202663607256
Otu0002 Otu00039 0.512465964406187
Otu0002 Otu00047 0.730301483589089
Otu0002 Otu00057 0.573490708638711
Otu0002 Otu00066 0.539961837085781
Otu0002 Otu00083 0.553157813265034
Otu0002 Otu00084 0.530240909220586
Otu0002 Otu00133 0.784857667907929
Otu0002 Otu00154 0.511528128122173
Otu0002 Otu00165 0.53831396859667
Otu0002 Otu00242 0.669315163629151
Otu0002 Otu00303 0.500475996445905
Otu0002 Otu00498 0.628615400548539
Otu0002 Otu00543 0.567818884280764
Otu0002 Otu00619 0.75244056951144
Otu0002 Otu00646 0.529522331732556
Otu0002 Otu00915 0.696241613567686
Otu0002 Otu00991 0.639059878477682
Otu0002 Otu01035 0.563754887455874
Otu0002 Otu01327 0.554745741443052
Otu0002 Otu01651 0.748640849069562
Otu0002 Otu01655 0.555344064103094
Otu0002 Otu01657 0.747195570271361
Otu0002 Otu01669 0.577474772318958
Otu0002 Otu01673 0.57235592816339
Otu0002 Otu01678 0.532054607967116
Otu0002 Otu01692 0.510778063738462
Otu0002 Otu01698 0.576035950309876
Otu0002 Otu01711 0.573412678434289
Otu0002 Otu01722 0.509439531502377
Otu0002 Otu01729 0.804007560392851
Otu0002 Otu01745 0.581593731432025
Otu0002 Otu01751 0.550207028205676
Otu0002 Otu01776 0.636377400797969
Otu0002 Otu01794 0.56342976112525
Otu0002 Otu01795 0.728674360956472
Otu0002 Otu01828 0.511204782529687
Otu0002 Otu01843 0.530105896684999
Otu0003 Otu00003 0.556594527311079
Otu0003 Otu00021 0.714168542495792
Otu0003 Otu00027 0.725098427544048
Otu0003 Otu00039 0.61965996355808
Otu0003 Otu00047 0.584934423175894
Otu0003 Otu00071 0.518614228559661
Otu0003 Otu00083 0.623468071193137
Otu0003 Otu00133 0.713676244293711
Otu0003 Otu00165 0.511466294820907
Otu0003 Otu00173 0.505441079098521
Otu0003 Otu00242 0.624930028988917
Otu0003 Otu00304 0.569530490988998
Otu0003 Otu00310 0.549922967908749
Otu0003 Otu00619 0.757942798980849
Otu0003 Otu00915 0.7176779954026
Otu0003 Otu00991 0.781576134554794
Otu0003 Otu01651 0.721487507136356
Otu0003 Otu01657 0.754496459495486
Otu0003 Otu01669 0.646458548457953
Otu0003 Otu01673 0.664770709865955
Otu0003 Otu01692 0.612569448712928
Otu0003 Otu01698 0.647668633288045
Otu0003 Otu01711 0.612561320274266
Otu0003 Otu01721 0.62061641275095
Otu0003 Otu01729 0.783249389771596
Otu0003 Otu01755 0.545766876049415
Otu0003 Otu01776 0.565929776218531
Otu0003 Otu01794 0.627392378650643
Otu0003 Otu01795 0.714717623091678
Otu0003 Otu01843 0.634005545496746
Otu0003 Otu01895 0.604070097405862
Otu0003 Otu02005 0.530714153809096
Otu0004 Otu00002 0.593137998828159
Otu0004 Otu00003 0.667086578833277
Otu0004 Otu00010 0.807842496549089
Otu0004 Otu00011 0.548624698052775
Otu0004 Otu00013 0.510344625908429
Otu0004 Otu00021 0.617648466154296
Otu0004 Otu00046 0.597857723445282
Otu0004 Otu00047 0.721857212062533
Otu0004 Otu00057 0.501491534404914
Otu0004 Otu00067 0.782197719763571
Otu0004 Otu00084 0.597125357015794
Otu0004 Otu00114 0.702886677174453
Otu0004 Otu00119 0.640090184931907
Otu0004 Otu00125 0.655686116969408
Otu0004 Otu00130 0.530181012591603
Otu0004 Otu00133 0.637948887965445
Otu0004 Otu00143 0.528939127164607
Otu0004 Otu00149 0.714451018178487
Otu0004 Otu00150 0.644296813063963
Otu0004 Otu00154 0.689195532237303
Otu0004 Otu00165 0.599856550664088
Otu0004 Otu00175 0.519602448838287
Otu0004 Otu00199 0.5829767621024
Otu0004 Otu00223 0.670053732330698
Otu0004 Otu00252 0.586402767458116
Otu0004 Otu00256 0.506550312986315
Otu0004 Otu00261 0.52655831389696
Otu0004 Otu00271 0.750524441430203
Otu0004 Otu00274 0.594215209143337
Otu0004 Otu00290 0.8790743770077
Otu0004 Otu00333 0.626301582988709
Otu0004 Otu00383 0.556202065156764
Otu0004 Otu00543 0.704129662960999
Otu0004 Otu00646 0.8271349261136
Otu0004 Otu00689 0.842186325891778
Otu0004 Otu00825 0.708565309478537
Otu0004 Otu00851 0.584203923919377
Otu0004 Otu00949 0.790579843465587
Otu0004 Otu00970 0.607709549330321
Otu0004 Otu01035 0.865518844853625
Otu0004 Otu01327 0.750309955803488
Otu0004 Otu01638 0.618105147426932
Otu0004 Otu01642 0.874270049304982
Otu0004 Otu01661 0.54192029772368
Otu0004 Otu01662 0.710040347441829
More information about the R-help
mailing list