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}
}
]

Correlation records

miRNA, Gene, R-square, m1, m2, nDp

Negative slope

negRecs=Import[ToFileName[outDir,"mir_gene.maturestar.c1.txt.filtered.txt.no0slope.25r.pt.mfilter.neg.rsort.txt"],"CSV"];
Dimensions[negRecs]
negRecs[[1;;4]]//TableForm

Only neg records for SFRP2

(*selNegRecs=Select[negRecs,(
StringMatchQ[
First[StringSplit[#[[2]],"|"]],
"SFRP2"]==True
)&];
Length[selNegRecs]*)

(*Export[ToFileName[outDir,"Wnt.pathway.SFRP2.c6.neg.txt"],selNegRecs,"TSV"]*)

Positive slope

posRecs=Import[ToFileName[outDir,"mir_gene.maturestar.c1.txt.filtered.txt.no0slope.25r.pt.mfilter.pos.rsort.txt"],"CSV"];
Dimensions[posRecs]
posRecs[[1;;4]]//TableForm

Pie chart of slopes

PieChart[{Length[posRecs],Length[negRecs]},
ChartLabels->{
StringJoin["m>0\n",ToString[Length[posRecs]]],
StringJoin["m<0\n",ToString[Length[negRecs]]],
},
ChartStyle->{Lighter[Lighter[Red]],Lighter[Lighter[Lighter[Blue]]]},
ImageSize->180,BaseStyle->Directive[14,(FontFamily->"Helvetica")]]

EDF of r2

r2Neg=negRecs[[All,3]];
Length[r2Neg]
rsR2Neg=RandomSample[r2Neg,1000];
r2Pos=posRecs[[All,3]];
rsR2Pos=RandomSample[r2Pos,1000];

plotTitle="COAD-READ c1, MSI"

r2Plot=Show[
ListLogLinearPlot[edfFn[rsR2Pos],Joined->False,PlotRange->{{0.2,1.0},{-0.02,1.02}},PlotStyle->Directive[Lighter[Red],Opacity[1],PointSize[0.0175]],listPlotOptions,FrameLabel->{"(r^2)","Fraction of records",plotTitle}],

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

ImageSize->300,ImageMargins->5]

Slopes

m1Neg=negRecs[[All,4]];
rsM1Neg=RandomSample[m1Neg,1000];
m1Pos=posRecs[[All,4]];
rsM1Pos=RandomSample[m1Pos,1000];
m1=Join[m1Neg,m1Pos];
rsM1=Join[rsM1Neg,rsM1Pos];
{Length[m1],Length[rsM1]}

edgeOp=0.3
ptSz=0.01
slopePlot=Show[
ListPlot[edfFn[rsM1],Joined->False,PlotRange->{{-3,3},{-0.02,1.02}},PlotStyle->Directive[Darker[Blue],Opacity[0.9],PointSize[0.012]],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[m1,0.10],0},{Quantile[m1,0.90],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.05],Rectangle[{Quantile[m1,0.05],0},{Quantile[m1,0.95],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.05],Rectangle[{Quantile[m1,0.02],0},{Quantile[m1,0.98],1.0}]}],
Graphics[{EdgeForm[{Blue,Thickness[0.001],Opacity[edgeOp]}],Darker[Blue],Opacity[0.07],Rectangle[{Quantile[m1,0.01],0},{Quantile[m1,0.99],1.0}]}],

ImageSize->300,ImageMargins->5]

Canonical 5’ starts

Records for Cytoscape

recs=Join[posRecs,negRecs];
Dimensions[recs]

recs[[1;;4]]//TableForm

forCytoscape=Table[
{
mir=StringReplace[recs[[i,1]],"hsa-"->""],
If[recs[[i,4]]>=0,"P","N"],
First[StringSplit[recs[[i,2]],"|"]],
recs[[i,3]],
N[1/recs[[i,3]]],
recs[[i,4]],
Abs[recs[[i,4]]],
Last[StringSplit[mir,"_"]],
recs[[i,6]]
(*recs[[i,1]]/.isomirExpnRules*)
},{i,Length[recs]}];//Timing
forCytoscape=Sort[forCytoscape,(#1[[4]]>#2[[4]])&];
forCytoscapePp=Prepend[forCytoscape,{"miR","interaction","gene","r2","1/r2","m","abs(m)","isomir","Ndp"}];
{Length[forCytoscape],"records"}
forCytoscapePp[[1;;20]]//TableForm

Export[ToFileName[outDir,"Wnt.pathway.grep-MSI.mir_gene.maturestar.c1.txt.filtered.txt.no0slope.25r.pt.mfilter.neg.rsort.Cytoscape.20110523.txt"],forCytoscapePp,"TSV"]

Compare validated targets to negative correlations

(*targetScanPredTgtsTab=Import["/Users/grobertson/GENEREG/Data/miRNA/TargetScan/human/Predicted_Targets_Info.WNT.txt","TSV"];
targetScanPredTgtsTab[[1]]
targetScanPredTgtsData=Drop[targetScanPredTgtsTab,1];
Dimensions[targetScanPredTgtsData]
targetScanPredTgtsData[[1;;5]]//TableForm*)

(*targetScanContextScoresTab=Import["/Users/grobertson/GENEREG/Data/miRNA/TargetScan/human/Conserved_Site_Context_Scores.WNT.txt","TSV"];
targetScanContextScoresTab[[1]]
targetScanContextScoresData=Drop[targetScanContextScoresTab,1];
Dimensions[targetScanContextScoresData]
targetScanContextScoresData[[1;;5]]//TableForm*)

Tarbase

(*tarbaseTab=Import["/Users/grobertson/GENEREG/Data/miRNA/TarBase/TarBase_V5.0.human.txt","TSV"];
tarbaseTab[[1]]
tarbaseData=Drop[tarbaseTab,1];
Dimensions[tarbaseData]
tarbaseData[[1;;5]]//TableForm*)

mirDIP target predictions (Shirdel PLoS-One 2011)

(*mirDipSfrpTab=Import["/Users/grobertson/GENEREG/ChIP/CHIP_SEQ/SOLEXA/TCGA/COAD-READ/data/miRNA-Seq/20110505/targets/mirDIP/mirDIP-Results.SFRP.2dbs.txt","TSV"];
mirDipSfrpTab[[1]]
mirDipSfrpData=Drop[mirDipSfrpTab,1];
Dimensions[mirDipSfrpData]
mirDipSfrpTab[[1;;5]]//TableForm*)