Skip to content

Commit

Permalink
Updates to graphing and calls to Distances.jl.
Browse files Browse the repository at this point in the history
  • Loading branch information
henselman-petrusek committed Mar 9, 2019
1 parent 64aecf1 commit c777b5c
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions src/Eirene.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ function persistf2vr(
if model == "pc" || model == "perseus_brips"
pc = "genera"
else
pc = "na"
pc = "n/a"
end

#### Store the input
Expand Down Expand Up @@ -1311,7 +1311,7 @@ function persistf2vr(
#### type the matrix
s = convert(Array{Float64,2},s)
if model == "pc"
d = Distances.pairwise(Euclidean(),s)
d = Distances.pairwise(Euclidean(),s,dims=2)
if !isempty(nodrad)
for i = 1:numpoints
d[i,i] = nodrad[i]
Expand Down Expand Up @@ -5242,6 +5242,7 @@ function classrep_pjs(
cloudcolor = [],
textlabels = [],
showlabels = false,
showedges = true,
alwaysshowcyclelabels = false)

###
Expand Down Expand Up @@ -5320,7 +5321,14 @@ function classrep_pjs(
cloudedges_orderverts = vetexinverter[cloudedges]
end

###
##############################################################################################
# WAYPOINT 1
# printval(coords,"coords")
# printval(coords==coords,"coords==coords")
# printval(D["input"]["pc"] == "n/a","D[\"input\"][\"pc\"] == \"n/a\"")
# printval(D["input"]["pc"],"D[\"input\"][\"pc\"]")
##############################################################################################

if coords == []
if D["input"]["pc"] == "n/a"
print("No point cloud is available. Please consider using the mds keyword argument to generate a Euclidean embedding from the distance matrix (see documentation).")
Expand All @@ -5340,8 +5348,8 @@ function classrep_pjs(
elseif coords == "mds"
if showcloud
if embeddingobj == "dmat"
metricmatrix = D["input"]["dmat"]
metricmatrix = metricmatrix - minimum(metricmatrix)
metricmatrix = D["input"]["genera"]
metricmatrix = metricmatrix .- minimum(metricmatrix)
for i = 1:size(metricmatrix,1)
metricmatrix[i,i]=0
end
Expand All @@ -5350,7 +5358,7 @@ function classrep_pjs(
end
else
if embeddingobj == "dmat"
metricmatrix = D["input"]["dmat"][classvinoldspace,classvinoldspace]
metricmatrix = D["input"]["genera"][classvinoldspace,classvinoldspace]
metricmatrix = metricmatrix - minimum(metricmatrix)
for i = 1:size(metricmatrix,1)
metricmatrix[i,i]=0
Expand All @@ -5360,7 +5368,7 @@ function classrep_pjs(
end
end
coords = classical_mds(metricmatrix,embeddingdim)
coords = round.(coords,10)
# coords = round.(coords,10)
model = "pc"
end

Expand Down Expand Up @@ -5411,6 +5419,13 @@ function classrep_pjs(
append!(data,[T2])
end

if showedges
faces = classrep(D,dim=dim,class=class)
edges = d1faces(faces)
T3 = edgetrace_pjs(coords,edges,model=model )
append!(data,T3)
end

if model == "pc"
dim = size(coords,1)
else
Expand Down Expand Up @@ -5444,7 +5459,8 @@ function plotclassrep_pjs(
classcolor = "spectral",
cloudcolor = [],
textlabels = [],
showlabels = "cycle")
showlabels = "cycle",
showedges = false)

if D["input"]["model"]!="pc" && D["input"]["pc"] == "n/a" && coords == []
print("No point cloud is available. Coordinates may be supplied by the user with the <coords> keyword argument, or generated automatically via the mds keyword argument. Please see documentation.")
Expand Down Expand Up @@ -5631,10 +5647,10 @@ function pcloudevec(pcloud;indices=1:size(pcloud,2),threshold = Inf,eval = 2)
l = length(indices)
if isodd(l)
A = zeros(l+1,l+1)
A[1:l,1:l] = Distances.pairwise(Euclidean(),pcloud)
A[1:l,1:l] = Distances.pairwise(Euclidean(),pcloud,dims=2)
eval = 3
else
A = Distances.pairwise(Euclidean(),pcloud)
A = Distances.pairwise(Euclidean(),pcloud,dims=2)
end

F = submatrixsublevellaplacianeigenstats(A,threshold = threshold,statrange = eval:eval)
Expand Down Expand Up @@ -5878,13 +5894,15 @@ function edgetrace_pjs(coordinates,edges;model="pc")
trace = PlotlyJS.scatter(
x = coordinates[1,verts],
y = coordinates[2,verts],
line = attr(color="#1f77b4", width=1.5),
mode = "lines",
name = "Dim 1 Faces")
edgetraces = [trace]
else
trace = PlotlyJS.scatter(
x = coordinates[1,verts],
y = coordinates[2,verts],
line = attr(color="#1f77b4", width=1.5),
mode = "lines",
name = "edge ($(verts[1]),$(verts[2]))",
showlegend = false)
Expand All @@ -5899,6 +5917,7 @@ function edgetrace_pjs(coordinates,edges;model="pc")
x = coordinates[1,verts],
y = coordinates[2,verts],
z = coordinates[3,verts],
line=attr(color="#1f77b4", width=1.5),
mode = "lines",
opacity = 0.5,
name = "Dim 1 Faces")
Expand All @@ -5908,6 +5927,7 @@ function edgetrace_pjs(coordinates,edges;model="pc")
x = coordinates[1,verts],
y = coordinates[2,verts],
z = coordinates[3,verts],
line=attr(color="#1f77b4", width=1.5),
name = "edge ($(verts[1]),$(verts[2]))",
showlegend = false,
mode = "lines",
Expand Down Expand Up @@ -7292,7 +7312,7 @@ end
function construction_sanitycheck(;numtrials = 10,samplesize = 50,sd=4)
for i = 1:numtrials
pcloud = rand(20,samplesize)
d = Distances.pairwise(Euclidean(),pcloud)
d = Distances.pairwise(Euclidean(),pcloud,dims=2)
(t,ocg2rad) = ordercanonicalform(d;fastop=false)
construction_sanitycheck_subroutine(t,sd,samplesize)
#gc()
Expand Down Expand Up @@ -8437,7 +8457,7 @@ function firstbcdiff(A,B;maxdim=1,offset=0) # stands for first barcode differenc
end

function colwised(x)
return Distances.pairwise(Euclidean(),x)
return Distances.pairwise(Euclidean(),x,dims=2)
end

function diagonalentries(x)
Expand Down Expand Up @@ -9159,9 +9179,9 @@ function writeperseusfile(

if model == "pc2vr"
if rowsare == "dimensions"
d = Distances.pairwise(Euclidean(),s)
d = Distances.pairwise(Euclidean(),s,dims=2)
elseif rowsare == "points"
d = Distances.pairwise(Euclidean(),s')
d = Distances.pairwise(Euclidean(),s',dims=2)
end
end

Expand Down Expand Up @@ -9217,7 +9237,7 @@ function writeperseusfile(
end
ambdim,numpts = size(s)
if nsteps == Inf
nsteps = 1 + ceil(Int64,maximum(Distances.pairwise(Euclidean(),s'))/stepsz)
nsteps = 1 + ceil(Int64,maximum(Distances.pairwise(Euclidean(),s',dims=2))/stepsz)
end
if isempty(pointbirths)
pointbirths = zeros(numpts)
Expand Down

0 comments on commit c777b5c

Please sign in to comment.