-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathposecpp_network.wl
More file actions
73 lines (54 loc) · 2.41 KB
/
Copy pathposecpp_network.wl
File metadata and controls
73 lines (54 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
(* ::Package:: *)
(* ::Title:: *)
(*Posecpp GRN & GEN*)
BeginPackage["Posecpp`"];
(* ::Section:: *)
(*Generate Network 2*)
Clear[LoadNetwork2Raw];Clear[ConstructNetwork2]
LoadNetwork2Raw[fn_]:=ReadList[fn,{Number,Number,Real,Real,Real,Real,Real,Real}];
ConstructNetwork2[rdata_,mincount_,totalvar_]:=
(* mincout = 100, totalvar=1~.5 *)
Module[{rgood1,rselected1,el},
rgood1=Select[rdata,#[[2]]>mincount&];
rgood1[[All,5]]=Sqrt[rgood1[[All,5]]];
rgood1[[All,3]]=Sqrt[rgood1[[All,3]]]/(Exp[rgood1[[All,8]]]+1);
rgood1[[All,4]]=Sqrt[rgood1[[All,4]]]/(Exp[rgood1[[All,8]]]+1);
rselected1=Select[rgood1,Total[#[[3;;5]]]<totalvar&&Quotient[#[[1]],10000]!=Mod[#[[1]],10000]&];
el = Map[Quotient[#[[1]],10000]<->Mod[#[[1]],10000]&,rselected1];
el
]
(* ::Section:: *)
(*Analyze Network 3*)
Clear[LoadNetwork3];
LoadNetwork3[fn_]:=Module[{el,g3,comm3},
Map[#[[1]]<->#[[2]]&,ReadList[fn,{Number,Number}]]]
(*g3 = Graph[el,VertexLabels->"Name"];
comm3 = FindGraphCommunities[g3]];*)
(* ::Section:: *)
(*Reading Global Data*)
Clear[LoadGlobalData]
LoadGlobalData[fnx_,fny_,fns_,fnn_]:=Module[{xvr,yvr,svr,noisyr,pickFinal,xv,yv,sv,nv,summary,gx,gy,gs,gn},
(*scale= ReadList[home<>"/geo/converge_s.txt",{Number,Real, Real,Real,Real, Real,Real, Real,Real,Real, Real,Real}][[;;,{1,12}]];*)
xvr= ToExpression//@StringSplit/@ReadList[fnx,Record];
yvr= ToExpression//@StringSplit/@ReadList[fny,Record];
svr= ToExpression//@StringSplit/@ReadList[fns,Record];
noisyr= ToExpression//@StringSplit/@ReadList[fnn,Record]/.{false->False,true->True};
pickFinal[x_]:=x[[;;,{1,-1}]];
xv=pickFinal[xvr];yv=pickFinal[yvr];sv=pickFinal[svr];nv=pickFinal[noisyr];summary=Join[xv,yv,sv,nv,2];
gx = Association[Map[Function[x,x[[1]]->x[[2]]],summary]];
gy = Association[Map[Function[x,x[[1]]->x[[4]]],summary]];
gs = Association[Map[Function[x,x[[1]]->x[[6]]],summary]];
gn = Association[Map[Function[x,x[[1]]->x[[8]]],summary]];
(*xmap=Select[(#->gx[#]+gs[#]/2 )&/@Range[1006],NumberQ[#[[2]]]&];*)
{gx,gy,gs,gn}
];
SLayer[keys_,ags_]:=Module[{sBin},
sBin = Exp[FindDivisions[Log[{Min[ags],Max[ags]}],10]]//N;
GroupBy[keys,Function[u, LengthWhile[sBin,ags[u]>#&]]]];
Clear[SLayerPlot];
SLayerPlot[ii_,asLayers_\:ff0cacx _,acy_]:=
Module[{pos,idx,name},
name = asLayers[ii];idx={name}//Transpose;
pos=Map[{acx[#],acy[#]}&,idx,{2}];
ListPlot[pos,PlotMarkers->Map[ToString,name],ImageSize->Large]]
EndPackage[]