miRNA-mRNA correlations

13 April 2011, 16h50

Directory

outDir="/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/COAD-READ/data/miRNA-Seq/20110505/correlations_k7/1"
Export[ToFileName[outDir,"test.txt"],{1,2,3}]

Plot setup

<<StatisticalPlots`

edfOptions={Frame->True,FrameStyle->Directive[12,(FontFamily->"Helvetica"),Black,Thickness[0.0016]],
LabelStyle->(FontFamily->"Helvetica"),Axes->None,
GridLines->Automatic,GridLinesStyle->Directive[Lighter[Gray]]};

pieChartOptions=BaseStyle->Directive[13,(FontFamily->"Helvetica")]

histogramOptions={Frame->True,FrameStyle->Directive[14,(FontFamily->"Helvetica"),Black,Thickness[0.0016]],
LabelStyle->(FontFamily->"Helvetica"),
GridLines->Automatic,GridLinesStyle->Directive[Lighter[Gray]]};
histogram3DOptions={AxesStyle->Directive[14,(FontFamily->"Helvetica"),Black,Thickness[0.001]],
LabelStyle->(FontFamily->"Helvetica")};

listPlotOptions={Frame->True,FrameStyle->Directive[14,(FontFamily->"Helvetica"),Black,Thickness[0.001]],
LabelStyle->Directive[14,FontFamily->"Helvetica"],Axes->None,
GridLines->Automatic,GridLinesStyle->Directive[Gray,Opacity[0.8]]};
listPlotOptionsInset={Frame->True,FrameStyle->Directive[20,(FontFamily->"Helvetica"),Black,Thickness[0.001]],
LabelStyle->(FontFamily->"Helvetica"),Axes->None,
GridLines->Automatic,GridLinesStyle->Directive[Gray,Opacity[0.6]]};

barchartOptions={Frame->True,BaseStyle->Directive[14,(FontFamily->"Helvetica")],
LabelStyle->(FontFamily->"Helvetica"),Axes->None,FrameTicks->{{Automatic,None},{None,None}},
GridLines->{None,Automatic},GridLinesStyle->Directive[Gray,Opacity[0.4]]};

edfFn[lis_]:=(
y=Table[N[i/Length[lis]],{i,Length[lis]}];
x=Sort[lis];
xy=Table[{x[[i]],y[[i]]},{i,Length[lis]}]
)

(* lis = {{name,value},{name,value},...}*)
edfWithNames[lis_]:=(
sortedLis=Sort[lis,(#1[[2]]<#2[[2]])&];
lisLen=Length[lis];
xy=Table[{sortedLis[[i,1]],sortedLis[[i,2]],N[i/lisLen]},{i,Length[lis]}]
)

edfFn[{1,2,3,4,5}]
edfWithNames[{
{"a",1},
{"b",5},
{"c",3},
{"d",4},
{"e",2}
}
]

miRecords target genes

miRecordsTab=Import["/Users/grobertson/GENEREG/Data/miRNA/miRecords/miRecords_version3.homo_sapeins.txt","TSV"];
miRecordsHdr=miRecordsTab[[1]]
miRecordsData=Drop[miRecordsTab,1];
Dimensions[miRecordsData]
miRecordsData[[1;;5]]//TableForm

Search on a gene symbol

recsForAGene=Select[miRecordsData,(
StringMatchQ[#[[4]],"RAD50"]==True
)&];
Tally[recsForAGene[[All,8]]]//TableForm

PhenomiR

phenomiRTab=Import["/Users/grobertson/GENEREG/RNA/miRNA/resources/PhenomiR/v2.0/phenomir.export.txt","TSV"];
phenomiRHdr=phenomiRTab[[1]]
phenomiRData=Drop[phenomiRTab,1];
Dimensions[phenomiRData]
phenomiRData[[1;;5]]//TableForm

Search on a miR

phenomiRData[[1]]

recsForAmiR=Select[phenomiRData,(
StringMatchQ[#[[5]],"hsa-mir-221"]==True
)&]
Tally[recsForAmiR[[All,8]]]//TableForm

IsomiR expression

isomiRExpressionTab=Import["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/LAML/correlations/20110409_new/isomiRs/miRNAseq.pct.above_10pct.txt","TSV"];
isomiRExpressionTab[[1;;5]]//TableForm

isomirsToRetain=isomiRExpressionTab[[2;;All,1]];
Length[isomirsToRetain]
isomirsToRetain[[1;;5]]

isomirExpnRules=Table[isomiRExpressionTab[[i,1]]->isomiRExpressionTab[[i,2]],{i,2,Length[isomiRExpressionTab]}];
isomirExpnRules[[1]]

isomirTallyTab=Table[
Flatten[{
StringSplit[isomiRExpressionTab[[i,1]],"_"],isomiRExpressionTab[[i]]
}],{i,2,Length[isomiRExpressionTab]}];
isomirTallyTab[[1;;5]]

myMiR="hsa-mir-148b"
myIsoMirs=Select[isomirTallyTab,(StringMatchQ[myMiR,#[[1]]]==True)&];
myIsoMirs=Table[
Flatten[{
myIsoMirs[[i,1]],
ToExpression[myIsoMirs[[i,2]]],
myIsoMirs[[i,3;;All]]}],
{i,Length[myIsoMirs]}];
myIsoMirs=Sort[myIsoMirs,(#1[[2]]<#2[[2]])&];
myIsoMirs//TableForm
BarChart[myIsoMirs[[All,4]],ChartLabels->myIsoMirs[[All,2]],BaseStyle->Directive[12,(FontFamily->"Helvetica")],AxesLabel->{StringDrop[myMiR,4],"RelExpn"},AspectRatio->2.5,ImageSize->120]

Relative expression levels of isomirs

isomirsPcts=ReadList["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/LAML/correlations/20110409_new/isomiRs/miRNAseq.pcts.txt","Number"];
Length[isomirsPcts]

ListPlot[edfFn[isomirsPcts],Joined->False,PlotRange->{{-0.02,1.02},{-0.02,1.02}},PlotStyle->Directive[Opacity[1],PointSize[0.009]],listPlotOptions,FrameLabel->{"Relative isomiR abundance","Fraction of isomiRs","LAML isomiRs"},ImageSize->400,ImageMargins->5]
ListLogLinearPlot[edfFn[isomirsPcts],Joined->False,PlotRange->{{(10^(-6)),1.5},{-0.02,1.02}},PlotStyle->Directive[Opacity[1],PointSize[0.009]],listPlotOptions,FrameLabel->{"Relative isomiR abundance","Fraction of isomiRs","LAML isomiRs"},ImageSize->400,ImageMargins->5]

Quantile[isomirsPcts,{0.5,0.6,0.7,0.8,0.9}]*100

Correlation records

miRNA,Gene,Gene name,R-square,Slope,Slope 0.05 CI,Slope 0.95 CI.,Slope 0.01 CI.,Slope 0.99 CI. Slope 0.001 CI, Slope .999 CI

[grobertson@xhost09 correlations]$ head hsa-mir-99b.txt
miRNA,Gene,Gene name,R-square,Slope,Slope 0.05 Conf. Int.,Slope 0.95 Conf. Int.
hsa-mir-99b,X..729884,?|729884,-0.000,-0.029,-0.143,0.085
hsa-mir-99b,X..8225,?|8225,0.001,0.135,0.000,0.270
hsa-mir-99b,X..90288,?|90288,0.033,0.265,0.220,0.309
hsa-mir-99b,A1BG.1,A1BG|1,0.004,0.269,0.139,0.400
hsa-mir-99b,A1CF.29974,A1CF|29974,0.004,0.139,0.076,0.202
hsa-mir-99b,A2BP1.54715,A2BP1|54715,0.034,0.355,0.296,0.414
...

Clear[data]
tab=Import["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/LAML/correlations/consensus_clusters/new/c1/all-mirs.no-Slope-or-NA.f0p001.c1.csv","CSV"];
hdr=tab[[1]];
Table[{i,hdr[[i]]},{i,Length[hdr]}]
data=Drop[tab,1];
Dimensions[data]
tab[[1;;5,1;;8]]//TableForm

(* 99.9% confidence intervals *)
r2Col=4;
slopeCol=5;
loCiCol=10;
hiCiCol=11;
loCiRslopeCol=19;
hiCiRslopeCol=20;
numDataPointsCol=22;

(*posRecs=Select[data,(#[[5]]>0)&];
zeroRecs=Select[data,(#[[5]]==0)&];
negRecs=Select[data,(#[[5]]<0)&];
{Length[posRecs],Length[zeroRecs],Length[negRecs]}//TableForm
PieChart[{Length[posRecs],Length[zeroRecs],Length[negRecs]},ChartLabels->{"pos","zero","neg"},ImageSize->220,BaseStyle->Directive[14,(FontFamily->"Helvetica")]]*)

Select records that correspond to retained isomiRs (Andy’s list)

retainedIsomirData=Select[data,(MemberQ[isomirsToRetain,#[[1]]]==True)&];//Timing
{Length[retainedIsomirData],Length[data],N[Length[retainedIsomirData]/Length[data]]}
retainedIsomirData[[1;;5]]

retainedIsomirDataNbrDataPoints=retainedIsomirData[[All,22]];
retainedIsomirDataNbrDataPoints[[1;;5]]

Nbr of data points for a relationship

numDataPoints=data[[All,numDataPointsCol]];
{Min[numDataPoints],Max[numDataPoints]}
rsNumDataPoints=RandomSample[numDataPoints,5000];

Show[
ListPlot[edfFn[rsNumDataPoints],Joined->False,PlotRange->{{-1,40},{-0.02,1.02}},PlotStyle->Directive[Opacity[1],PointSize[0.009]],listPlotOptions,FrameLabel->{"Nbr of data points","Fraction of records","LAML: c1, f=0.001 random subset"}],

ListPlot[edfFn[retainedIsomirDataNbrDataPoints],Joined->False,PlotRange->{{-100,13000},{-0.02,1.02}},PlotStyle->Directive[Green,Opacity[1],PointSize[0.009]]],

(*Graphics[{Red,Line[{{1000,0},{1000,1}}]}],*)
ImageSize->400,ImageMargins->5]

Show[
ListLogLinearPlot[edfFn[rsNumDataPoints],Joined->False,PlotRange->{{1,50},{-0.02,1.02}},PlotStyle->Directive[Opacity[1],PointSize[0.009]],listPlotOptions,FrameLabel->{"Nbr of data points","Fraction of records","LAML, f=0.001 random subset"}],

ListLogLinearPlot[edfFn[retainedIsomirDataNbrDataPoints],Joined->False,PlotRange->{{1,15000},{-0.02,1.02}},PlotStyle->Directive[Green,Opacity[1],PointSize[0.009]]],

ImageSize->400,ImageMargins->5]

qList={0.5,0.55,0.6,0.7,0.8,0.9}
Grid[
Prepend[
Transpose[{
qList,
Quantile[numDataPoints,qList],
Quantile[retainedIsomirDataNbrDataPoints,qList]
}],{"Quantile","N","Nri"}],
Frame->All,Alignment->Left]

Select records that have at least a threshold number of data points

threshNbrDataPts=20

selData=Select[retainedIsomirData,(#[[numDataPointsCol]]>=threshNbrDataPts)&];//Timing
{Length[selData],Length[retainedIsomirData],N[Length[selData]/Length[retainedIsomirData]]}

selData[[1]]
isomirsToRetain[[1;;15]]

Records where the slope confidence interval includes zero

Check a record

(*Needs["ErrorBarPlots`"]*)

(*rec=data[[1]]
Abs[rec[[lowCiCol]]-rec[[5]]]
Abs[rec[[hiCiCol]]-rec[[5]]]
ErrorListPlot[{
{
{1,rec[[5]]},
ErrorBar[{
Abs[rec[[loCiCol]]-rec[[5]]],Abs[rec[[hiCiCol]]-rec[[5]]]
}]
}
},PlotMarkers->{○,15},PlotRange->All]*)

Records with zero within the confidence interval on the ‘m’ slope

dataZeroCiM=Select[selData,(#[[loCiCol]]≤0.0&&#[[hiCiCol]]≥0)&];//Timing
{Length[dataZeroCiM],Length[selData],N[Length[dataZeroCiM]/Length[selData]],Length[selData]-Length[dataZeroCiM]}

Records with zero within the confidence interval on the ‘r’ slope

(*dataZeroCiMRlope=Select[selData,(#[[loCiRslopeCol]]≤0.0&&#[[hiCiRslopeCol]]≥0)&];//Timing
{Length[dataZeroCiMRlope],Length[selData],N[Length[dataZeroCiMRlope]/Length[selData]],Length[selData]-Length[dataZeroCiMRlope]}*)

Records with zero within the confidence interval on the ‘m’ slope OR ‘r’ slope

(*dataZeroCiMMslopeOrRlope=Select[selData,(
(#[[loCiCol]]≤0.0&&#[[hiCiCol]]≥0)
||
(#[[loCiRslopeCol]]≤0.0&&#[[hiCiRslopeCol]]≥0)
)&];//Timing
{Length[dataZeroCiMMslopeOrRlope],Length[selData],N[Length[dataZeroCiMMslopeOrRlope]/Length[selData]],Length[selData]-Length[dataZeroCiMMslopeOrRlope]}*)

{loCiCol,hiCiCol,loCiRslopeCol,hiCiRslopeCol}

(*dataZeroCiMMslopeANDRlope=Select[selData,(
(#[[loCiCol]]≤0.0&&#[[hiCiCol]]≥0)
&&
(#[[loCiRslopeCol]]≤0.0&&#[[hiCiRslopeCol]]≥0)
)&];//Timing
{Length[dataZeroCiMMslopeANDRlope],Length[selData],N[Length[dataZeroCiMMslopeANDRlope]/Length[selData]],Length[selData]-Length[dataZeroCiMMslopeANDRlope]}*)

(*Transpose[{hdr,dataZeroCiMMslopeANDRlope[[1]]}]//TableForm*)

Records with zero OUTSIDE the confidence interval on the m-slope

dataNzCiM=Select[selData,(0.0<#[[loCiCol]]||#[[hiCiCol]]<0.0)&];//Timing
{Length[dataNzCiM],Length[selData],N[Length[dataNzCiM]/Length[selData]]}
Length[dataNzCiM]+Length[dataZeroCiM]

dataNzPosM=Select[dataNzCiM,(#[[slopeCol]]>0.0)&];
dataNzZeroM=Select[dataNzCiM,(#[[slopeCol]]==0.0)&];
dataNzNegM=Select[dataNzCiM,(#[[slopeCol]]<0.0)&];
{{"pos",
Length[dataNzPosM],
N[Length[dataNzPosM]/Length[dataNzCiM]]},
{"zero",
Length[dataNzZeroM]},
{"neg",
Length[dataNzNegM],
N[Length[dataNzNegM]/Length[dataNzCiM]]},
{Length[dataNzPosM]+Length[dataNzNegM],
Length[dataNzPosM]+Length[dataNzNegM]+Length[dataZeroCiM]}}

PieChart[{Length[dataNzPosM],Length[dataNzNegM],Length[dataZeroCiM]},
ChartLabels->{
StringJoin["m>0\n",ToString[Length[dataNzPosM]]],
StringJoin["m<0\n",ToString[Length[dataNzNegM]]],
StringJoin["m≈0\n99.9% CI\n",ToString[Length[dataZeroCiM]]],
},
ChartStyle->{Lighter[Lighter[Red]],Lighter[Lighter[Blue]],Lighter[Lighter[Gray]]},
ImageSize->220,BaseStyle->Directive[14,(FontFamily->"Helvetica")]]

(*tallyNzCiMiRs=Tally[dataZeroCiM[[2;;All,1]]];
sortedTallyNzCiMiRs=Sort[tallyNzCiMiRs,(#1[[2]]>#2[[2]])&]*)

R-square

r2=selData[[All,4]];
Quantile[r2,{0.9,0.95,0.98,0.99}]

r2NzCiM=dataNzCiM[[All,4]];
Quantile[r2NzCiM,{0.9,0.95,0.98,0.99,0.995,0.999}]

r2NzMPos=dataNzPosM[[All,4]];
{"pos slopes>",Min[r2NzMPos],Max[r2NzMPos]}
Quantile[r2NzMPos,{0.9,0.95,0.98,0.99,0.999}]
(*rsR2NzMPos=RandomSample[r2NzMPos,10000];*)

r2NzMNeg=dataNzNegM[[All,4]];
{"neg slopes>",Min[r2NzMNeg],Max[r2NzMNeg]}
Quantile[r2NzMNeg,{0.9,0.95,0.98,0.99,0.999}]
(*rsR2NzMNeg=RandomSample[r2NzMNeg,10000];*)

plotTitle="LAML: c1, f=0.001 (m≠0)"

r2Plot=Show[
ListLogLinearPlot[edfFn[r2NzMPos],Joined->False,PlotRange->{{0.001,1.5},{-0.02,1.02}},PlotStyle->Directive[Lighter[Red],Opacity[0.5],PointSize[0.01]],listPlotOptions,FrameLabel->{"(r^2)","Fraction of records",plotTitle}],

ListLogLinearPlot[edfFn[r2NzMNeg],Joined->False,PlotStyle->Directive[Darker[Blue],Opacity[0.5],PointSize[0.01]]],
(*Graphics[{Darker[Blue],Opacity[0.1],Rectangle[{Log[(10^(-5))],Log[0.003]},{0.0,1.0}]}],*)

ImageSize->400,ImageMargins->5]

[grobertson@xhost09 correlation]$ ll -h all*
-rw-rw-r-- 1 grobertson users 1.3G Feb  7 21:07 all.mir.files
[grobertson@xhost09 correlation]$ awk ‘{ if(rand()<0.002) { print > “all.mir.files.clean.f0p002.txt” } }’ all.mir.files.clean

Slopes

(*slopePos=dataNzPosM[[All,5]];
{"pos>",Min[slopePos],Max[slopePos]}
(*rsSlopePos=RandomSample[slopePos,10000];*)
Quantile[slopePos,{0.9,0.95,0.98,0.99}]

slopeNeg=dataNzNegM[[All,5]];
{"neg>",Min[slopeNeg],Max[slopeNeg]}
(*rsSlopeNeg=RandomSample[slopeNeg,10000];*)
Quantile[slopeNeg,{0.01,0.02,0.05,0.1}]*)

(*Show[
ListPlot[edf[rsSlopeNeg],PlotRange->{{-1.5,1.5},{-0.02,1.02}},PlotStyle->Directive[Darker[Blue],Opacity[0.5],PointSize[0.01]],listPlotOptions,FrameLabel->{"Slope","Fraction of records","~50k random records"}],
ListPlot[edf[rsSlopePos],PlotStyle->Directive[Darker[Green],Opacity[0.5],PointSize[0.01]]],
ImageSize->400,ImageMargins->5
]*)

slopesNzCiM=dataNzCiM[[All,slopeCol]];
(*rsSlopesNzCiM=RandomSample[slopesNzCiM,10000];*)
{Min[slopesNzCiM],Max[slopesNzCiM]}
Quantile[slopesNzCiM,{0.01,0.02,0.05,0.1,0.9,0.95,0.98,0.99}]

edgeOp=0.3
slopePlot=Show[
ListPlot[edfFn[slopesNzCiM],Joined->False,PlotRange->{{-3,3},{-0.02,1.02}},PlotStyle->Directive[Darker[Blue],Opacity[0.9],PointSize[0.008]],listPlotOptions,FrameLabel->{"m","Fraction of records",plotTitle}],

(*ListLogLinearPlot[edf[rsSlopeNeg],Joined->False,PlotStyle->Directive[Darker[Blue],Opacity[0.5],PointSize[0.01]]],*)
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.05],Rectangle[{Quantile[slopesNzCiM,0.10],0},{Quantile[slopesNzCiM,0.90],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.05],Rectangle[{Quantile[slopesNzCiM,0.05],0},{Quantile[slopesNzCiM,0.95],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.05],Rectangle[{Quantile[slopesNzCiM,0.02],0},{Quantile[slopesNzCiM,0.98],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.07],Rectangle[{Quantile[slopesNzCiM,0.01],0},{Quantile[slopesNzCiM,0.99],1.0}]}],

ImageSize->400,ImageMargins->5]

miRs with the highest slopes or highest r2

t1=Table[
ss=StringSplit[dataNzCiM[[i,3]],"|"];
{
StringReplace[dataNzCiM[[i,1]],"hsa-"->""],
(*If[dataNzCiM[[i,5]]>=0,"P","N"],*)
ss[[1]],
dataNzCiM[[i,4]],
dataNzCiM[[i,5]],
Abs[dataNzCiM[[i,5]]],
dataNzCiM[[i,22]]
},{i,Length[dataNzCiM]}];//Timing

st1=Sort[t1,(#1[[5]]>#2[[5]])&];
st1Pp=Prepend[st1,{"miR","gene","r2","m","abs(m)[sort]","Nbr recs"}];
st1Pp[[1;;36]]//TableForm

st4=Sort[t1,(#1[[3]]>#2[[3]])&];
st4Pp=Prepend[st4,{"miR","gene","r2[sort]","m","abs(m)","Nbr recs"}];
st4Pp[[1;;36]]//TableForm

Density plot

dataNZ=Select[dataNzCiM,(#[[4]]>0.01)&];
{Length[dataNZ],Length[data]}
forDensity=Table[{Log10[dataNZ[[i,4]]],dataNZ[[i,5]]},{i,Length[dataNZ]}];
forDensity[[1;;5]]//TableForm

Histogram3D[forDensity,ChartElementFunction->"GradientScaleCube",ChartLabels->{"(r^2)","m","records"}]

bc=BinCounts[forDensity,{-2,-0.7,0.05},{-1.2,1.2,0.1}];
bc;//TableForm
ArrayPlot[bc,Mesh->All,MeshStyle->Opacity[0.3]]
ListContourPlot[bc,InterpolationOrder->2,PlotRange->All,Contours->20,ColorFunction->"PearlColors",DataRange->{{-1.,1.},{-2,-0.7}},FrameLabel->{"m","(Subscript[log, 10])((r^2))"},BaseStyle->Directive[14,(FontFamily->"Helvetica")]]

Transform an awk’d filtered correlation file into a graph or a Cytoscape file

awk -F, ‘{ if( $4 >= 0.15 && ($5 <= -0.5 || $5 >= 0.5) && $22 > 500 ) { print $0 } }’ all.hsa-mir.txt | grep -v “NA,” > all.mirs.r2-ge-0.15_0p5-slope-0p5.n500.no-NA.20110410.txt

Read in awk’d file

(* AML *)
filteredCorrData=Import["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/LAML/correlations/20110410/all.mirs.r2-ge-0.15__0p5-slope-0p5.n500.no-NA.20110410.txt","CSV"];
Dimensions[filteredCorrData]
filteredCorrData[[1;;5]]//TableForm

Retain only records corresponding to relatively abundant isomiRs

retainedIsomirFilteredCorrData=Select[filteredCorrData,(MemberQ[isomirsToRetain,#[[1]]]==True)&];//Timing
{Length[retainedIsomirFilteredCorrData],Length[filteredCorrData],N[Length[retainedIsomirFilteredCorrData]/Length[filteredCorrData]]}
retainedIsomirFilteredCorrData[[1;;5]]

Check numbers of data points

nbrs=retainedIsomirFilteredCorrData[[All,22]];
rsNbrs=RandomSample[nbrs,1000];
rsNbrs[[1;;10]]
Show[
ListLogLinearPlot[edfFn[rsNumDataPoints],Joined->False,PlotRange->{{1,15000},{-0.02,1.02}},PlotStyle->Directive[Opacity[1],PointSize[0.009]],listPlotOptions,FrameLabel->{"Nbr of data points","Fraction of records","LAML, f=0.001 & high-ranked subsets"}],

ListLogLinearPlot[edfFn[retainedIsomirDataNbrDataPoints],Joined->False,PlotRange->{{1,15000},{-0.02,1.02}},PlotStyle->Directive[Green,Opacity[1],PointSize[0.009]]],

ListLogLinearPlot[edfFn[rsNbrs],Joined->False,PlotRange->{{1,15000},{-0.02,1.02}},PlotStyle->Directive[Black,Opacity[1],PointSize[0.009]]],

ImageSize->400,ImageMargins->5]

Check r2

finalR2=retainedIsomirFilteredCorrData[[All,r2Col]];
rsFinalR2=RandomSample[finalR2,5000];
rsFinalR2[[1;;10]]
Show[
ListLogLinearPlot[edfFn[r2NzMPos],Joined->False,PlotRange->{{0.0005,0.6},{-0.02,1.02}},PlotStyle->Directive[Lighter[Red],Opacity[0.5],PointSize[0.012]],listPlotOptions,FrameLabel->{"(r^2)","Fraction of records","LAML, f=0.001 & highly-ranked subsets"}],

ListLogLinearPlot[edfFn[r2NzMNeg],Joined->False,PlotStyle->Directive[Darker[Blue],Opacity[0.5],PointSize[0.012]]],
(*Graphics[{Darker[Blue],Opacity[0.1],Rectangle[{Log[(10^(-5))],Log[0.003]},{0.0,1.0}]}],*)

ListLogLinearPlot[edfFn[rsFinalR2],Joined->False,PlotStyle->Directive[Black,Opacity[0.5],PointSize[0.009]]],

ImageSize->400,ImageMargins->5]

Check slopes

mSlopes=retainedIsomirFilteredCorrData[[All,slopeCol]];
rsMSlopes=RandomSample[mSlopes,5000];
rsMSlopes[[1;;10]]
Show[
ListPlot[edfFn[slopesNzCiM],Joined->False,PlotRange->{{-2,2},{-0.02,1.02}},PlotStyle->Directive[Darker[Blue],Opacity[0.9],PointSize[0.008]],listPlotOptions,FrameLabel->{"m","Fraction of records","LAML, f=0.001 & high-ranked subsets"}],

ListPlot[edfFn[rsMSlopes],Joined->False,PlotStyle->Directive[Black,Opacity[0.9],PointSize[0.008]]],

(*ListLogLinearPlot[edf[rsSlopeNeg],Joined->False,PlotStyle->Directive[Darker[Blue],Opacity[0.5],PointSize[0.01]]],*)
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.05],Rectangle[{Quantile[slopesNzCiM,0.10],0},{Quantile[slopesNzCiM,0.90],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.05],Rectangle[{Quantile[slopesNzCiM,0.05],0},{Quantile[slopesNzCiM,0.95],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.05],Rectangle[{Quantile[slopesNzCiM,0.02],0},{Quantile[slopesNzCiM,0.98],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.07],Rectangle[{Quantile[slopesNzCiM,0.01],0},{Quantile[slopesNzCiM,0.99],1.0}]}],

ImageSize->400,ImageMargins->5]

Survey retained records for pos/neg slopes

retainedIsomirFilteredCorrData[[1]]
retainedIsomirFilteredCorrData[[1,slopeCol]]
Abs[retainedIsomirFilteredCorrData[[1,slopeCol]]]

{Min[retainedIsomirFilteredCorrData[[All,5]]],Max[retainedIsomirFilteredCorrData[[All,5]]]}

trifcd=Tally[Table[If[filteredCorrData[[i,slopeCol]]>=0,"P","N"],{i,Length[filteredCorrData]}]]
PieChart[trifcd[[All,2]],
ChartLabels->{
StringJoin["m>0\n",ToString[trifcd[[1,2]]]],
StringJoin["m<0\n",ToString[trifcd[[2,2]]]]
},
ChartStyle->{Lighter[Red],Lighter[Lighter[Blue]]},
ImageSize->220,BaseStyle->Directive[14,(FontFamily->"Helvetica")]]

Table[{i,hdr[[i]]},{i,Length[hdr]}]

forCytoscape=Table[
ss=StringSplit[retainedIsomirFilteredCorrData[[i,3]],"|"];
{
mir=StringReplace[retainedIsomirFilteredCorrData[[i,1]],"hsa-"->""],
If[retainedIsomirFilteredCorrData[[i,5]]>=0,"P","N"],
ss[[1]],
retainedIsomirFilteredCorrData[[i,4]],
N[1/retainedIsomirFilteredCorrData[[i,4]]],
retainedIsomirFilteredCorrData[[i,5]],
Abs[retainedIsomirFilteredCorrData[[i,5]]],
Last[StringSplit[mir,"_"]],
retainedIsomirFilteredCorrData[[i,22]],
retainedIsomirFilteredCorrData[[i,1]]/.isomirExpnRules
},{i,Length[retainedIsomirFilteredCorrData]}];//Timing
forCytoscapePp=Prepend[forCytoscape,{"miR","interaction","gene","r2","1/r2","m","abs(m)","isomir","Ndp","relExpn"}];
{Length[forCytoscape],"records"}
forCytoscapePp[[1;;20]]//TableForm

(*Export[ToFileName[outDir,"all.mir.files.CIs.clean.r2-ge-0.145__0p881-slope-0p833.for-cytoscape.unsorted.20110209.txt"],forCytoscapePp,"TSV"]*)

Tally[forCytoscape[[All,2]]]

topN=500
forCytoscapeSorted=Sort[forCytoscape,(#1[[7]]>#2[[7]])&];
forCytoscapeSortedTopN=Take[forCytoscapeSorted,topN];
Dimensions[forCytoscapeSortedTopN]
{"slopes>",Tally[forCytoscapeSortedTopN[[2;;All,2]]]}
forCytoscapeSortedTopNPp=Prepend[forCytoscapeSortedTopN,{"miR","interaction","gene","r2","1/r2","m","abs(m)","isomir","Ndp","relExpn"}];
forCytoscapeSortedTopNPp[[1;;20]]//TableForm

Export["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/LAML/correlations/20110410/LAML.all.mirs.r2-ge-0.15__0p5-slope-0p5.n500.no-NA.for-Cytoscape.top-500-absSlope.20110410.txt",forCytoscapeSortedTopNPp,"TSV"]

Tally miRNA connections

tallyMiRs=Tally[forCytoscapeSortedTopNPp[[2;;All,1]]];
sortedTallyMiRs=Sort[tallyMiRs,(#1[[2]]>#2[[2]])&];
selSortedTallyMiRs=Select[sortedTallyMiRs,(#[[2]]>=5)&];
selSortedTallyMiRs//TableForm
BarChart[Reverse[selSortedTallyMiRs[[All,2]]],BarOrigin->Left,ChartLabels->Reverse[selSortedTallyMiRs[[All,1]]],AspectRatio->1.5,ImageSize->300,BaseStyle->Directive[11,(FontFamily->"Helvetica")],GridLines->{Automatic,None}(*,AxesLabel->{"Targets","AML"}*)]

Tally gene connections

tallyGenes=Tally[forCytoscapeSortedTopNPp[[2;;All,3]]];
sortedTallyGenes=Sort[tallyGenes,(#1[[2]]>#2[[2]])&];
selSortedTallyGenes=Select[sortedTallyGenes,(#[[2]]>=5)&];
selSortedTallyGenes//TableForm
BarChart[Reverse[selSortedTallyGenes[[All,2]]],BarOrigin->Left,ChartLabels->Reverse[selSortedTallyGenes[[All,1]]],AspectRatio->1.5,ImageSize->250,BaseStyle->Directive[11,(FontFamily->"Helvetica")],GridLines->{Automatic,None}(*,AxesLabel->{"Targets","AML"}*)]

Graph

Graph[
Table[corrData[[i,1]]<->corrData[[i,3]],{i,Length[corrData]}],
VertexLabels->"Name",ImagePadding->10,ImageSize->600,ImageMargins->5
]

Transform a filtered correlation file into a graph or a Cytoscape file

corrData1=Import["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/LAML/correlations/20110208/all.mir.files.r2-ge-0.5_abs-slope-ge-0.25.20110208.txt","CSV"];
Dimensions[corrData1]
corrData1[[1;;5]]//TableForm

cytoscapeTab=Table[
Flatten[{
corrData1[[i,1]],
If[corrData1[[i,5]]>0,"pos","neg"],
corrData1[[i,3]],
corrData1[[i,4]],
corrData1[[i,5]],
Abs[corrData1[[i,5]]]
}],{i,Length[corrData1]}];
cytoscapeTabPp=Prepend[cytoscapeTab,{"miR","correlation","gene","r2","slope","absSlope"}];
cytoscapeTabPp[[1;;5]]//TableForm

Export["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/LAML/correlations/20110208/all.mir.files.r2-ge-0.5_abs-slope-ge-0.25.for-cytoscape.20110208.txt",cytoscapeTabPp,"TSV"]

Graph[
Table[corrData1[[i,1]]<->corrData1[[i,3]],{i,Length[corrData1]}]
]

Isomirs

isomirsPcts=ReadList["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/LAML/correlations/20110409/miRNAseq.pcts.txt","Number"];
Length[isomirsPcts]

ListPlot[edfFn[isomirsPcts],Joined->False,PlotRange->{{-0.02,1.02},{-0.02,1.02}},PlotStyle->Directive[Opacity[1],PointSize[0.009]],listPlotOptions,FrameLabel->{"Relative isomiR abundance","Fraction of isomiRs","LAML isomiRs"},ImageSize->400,ImageMargins->5]
ListLogLinearPlot[edfFn[isomirsPcts],Joined->False,PlotRange->{{(10^(-6)),1.5},{-0.02,1.02}},PlotStyle->Directive[Opacity[1],PointSize[0.009]],listPlotOptions,FrameLabel->{"Relative isomiR abundance","Fraction of isomiRs","LAML isomiRs"},ImageSize->400,ImageMargins->5]

Needs["Units`"]

Quantile[isomirsPcts,{0.5,0.6,0.7,0.8,0.9}]*100