Skip to content

Commit

Permalink
Project.toml; new indexing rules from DataFrames v0.19
Browse files Browse the repository at this point in the history
fix R install on Travis
  • Loading branch information
cecileane committed Aug 21, 2019
1 parent 180b22e commit 80c0ce6
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 66 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.jl.mem
docs/build/
docs/site/
*Manifest.toml
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ os:
- linux
- osx
julia:
- 1.0
- 1.1
- 1.2

notifications:
email: false
git:
Expand All @@ -22,7 +24,7 @@ before_install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y "deb http://cran.rstudio.com/bin/linux/ubuntu $(lsb_release -s -c)/"; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq -y; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install git r-base r-base-dev r-recommended -y; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --allow-unauthenticated git r-base r-base-dev r-recommended -y; fi

# osx
# faster than using homebrew/science tap
Expand All @@ -36,7 +38,7 @@ coveralls: true
jobs:
include:
- stage: "Documentation"
julia: 1.0
julia: 1.2
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.instantiate();
Expand Down
27 changes: 27 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name = "PhyloPlots"
uuid = "c0d5b6db-e3fc-52bc-a87d-1d050989ed3b"
license = "MIT"
version = "0.2.1"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
PhyloNetworks = "33ad39ac-ed31-50eb-9b15-43d0656eaa72"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"

[compat]
DataFrames = "≥ 0.13.0"
Gadfly = "≥ 1.0.0"
PhyloNetworks = "≥ 0.9.0"
RCall = "≥ 0.11.0"
julia = "≥ 0.7.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
7 changes: 0 additions & 7 deletions REQUIRE

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ DocumenterMarkdown = "997ab1e6-3595-5248-9280-8efb232c3433"
# PhyloNetworks = "33ad39ac-ed31-50eb-9b15-43d0656eaa72"

[compat]
Documenter = "~0.21"
Documenter = "~0.23"
22 changes: 11 additions & 11 deletions src/phylonetworksPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ Check data frame for node annotations:
"""
function checkNodeDataFrame(net::HybridNetwork, nodeLabel::DataFrame)
labelnodes = size(nodeLabel,1)>0
if (labelnodes && (size(nodeLabel,2)<2 || !(Missings.T(eltype(nodeLabel[1])) <: Integer)))
if (labelnodes && (size(nodeLabel,2)<2 || !(Missings.T(eltypes(nodeLabel)[1]) <: Integer)))
@warn "nodeLabel should have 2+ columns, the first one giving the node numbers (Integer)"
labelnodes = false
end
if labelnodes # remove rows with no node number, check if at least one row remains
nodeLabel = nodeLabel[.~ismissing.(nodeLabel[1]),:]
filter!(row->!ismissing(row[1]), nodeLabel)
labelnodes = size(nodeLabel,1)>0
end
if labelnodes
tmp = setdiff(nodeLabel[1], [n.number for n in net.node])
tmp = setdiff(nodeLabel[!,1], [n.number for n in net.node])
if length(tmp)>0
msg = "Some node numbers in the nodeLabel data frame are not found in the network:\n"
for a in tmp msg *= string(" ",a); end
Expand Down Expand Up @@ -218,12 +218,12 @@ function prepareNodeDataFrame(net::HybridNetwork, nodeLabel::DataFrame,
ndf[j,:name] = net.node[i].name
ndf[j,:num] = string(net.node[i].number)
if labelnodes
jn = findfirst(isequal(net.node[i].number), nodeLabel[1])
jn = findfirst(isequal(net.node[i].number), nodeLabel[!,1])
ndf[j,:lab] = (jn===nothing || ismissing(nodeLabel[jn,2]) ? "" : # node label not in table or missing
(Missings.T(eltype(nodeLabel[2])) <: AbstractFloat ?
(Missings.T(eltypes(nodeLabel)[2]) <: AbstractFloat ?
@sprintf("%0.3g",nodeLabel[jn,2]) : string(nodeLabel[jn,2])))
end
ndf[j,:lea] = net.node[i].leaf # use this later to remove #H? labels
ndf[j,:lea] = net.node[i].leaf # use this later to remove H? labels
ndf[j,:y] = node_y[i]
ndf[j,:x] = node_x[i]
j += 1
Expand Down Expand Up @@ -256,16 +256,16 @@ function prepareEdgeDataFrame(net::HybridNetwork, edgeLabel::DataFrame, mainTree
[Symbol("len"),Symbol("gam"),Symbol("num"),Symbol("lab"),
Symbol("hyb"),Symbol("min"),Symbol("x"),Symbol("y")], nrows)
labeledges = size(edgeLabel,1)>0
if (labeledges && (size(edgeLabel,2)<2 || !(Missings.T(eltype(edgeLabel[1])) <: Integer)))
if (labeledges && (size(edgeLabel,2)<2 || !(Missings.T(eltypes(edgeLabel)[1]) <: Integer)))
@warn "edgeLabel should have 2+ columns, the first one giving the edge numbers (Integer)"
labeledges = false
end
if labeledges # remove rows with no edge number and check if at least one remains
edgeLabel = edgeLabel[.~ismissing.(edgeLabel[1]),:]
filter!(row->!ismissing(row[1]), edgeLabel)
labeledges = size(edgeLabel,1)>0
end
if labeledges
tmp = setdiff(edgeLabel[1], [e.number for e in net.edge])
tmp = setdiff(edgeLabel[!,1], [e.number for e in net.edge])
if length(tmp)>0
msg = "Some edge numbers in the edgeLabel data frame are not found in the network:\n"
for a in tmp msg *= string(" ",a); end
Expand All @@ -280,9 +280,9 @@ function prepareEdgeDataFrame(net::HybridNetwork, edgeLabel::DataFrame, mainTree
edf[j,:gam] = (net.edge[i].gamma==-1.0 ? "" : @sprintf("%0.3g",net.edge[i].gamma))
edf[j,:num] = string(net.edge[i].number)
if labeledges
je = findfirst(isequal(net.edge[i].number), edgeLabel[1])
je = findfirst(isequal(net.edge[i].number), edgeLabel[!,1])
edf[j,:lab] = (je===nothing || ismissing(edgeLabel[je,2]) ? "" : # edge label not found in table
(Missings.T(eltype(edgeLabel[2])) <: AbstractFloat ?
(Missings.T(eltypes(edgeLabel)[2]) <: AbstractFloat ?
@sprintf("%0.3g",edgeLabel[je,2]) : string(edgeLabel[je,2])))
end
edf[j,:hyb] = net.edge[i].hybrid
Expand Down
18 changes: 9 additions & 9 deletions src/plotGadfly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Plots a network, from left to right.
- minorHybridEdgeColor: color for minor hybrid edges
- showEdgeNumber: if true, edges are labelled with the number used internally.
- showIntNodeLabel: if true, internal nodes are labelled with their names.
Useful for hybrid nodes, which do have tags like '#H1'.
Useful for hybrid nodes, which do have tags like 'H1'.
- edgeLabel: dataframe with two columns: the first with edge numbers, the second with labels
(like bootstrap values) to annotate edges. empty by default.
- nodeLabel: dataframe with two columns: the first with node numbers, the second with labels
Expand Down Expand Up @@ -81,45 +81,45 @@ function Gadfly.plot(net::HybridNetwork; useEdgeLength=false::Bool,
ndf = prepareNodeDataFrame(net, nodeLabel, showNodeNumber,
showIntNodeLabel, labelnodes, node_x, node_y)
if (showTipLabel)
push!(mylayers, layer(ndf[ndf[:lea], [:x,:y,:name]], y="y", x="x", label="name",
push!(mylayers, layer(ndf[ndf[!,:lea], [:x,:y,:name]], y="y", x="x", label="name",
Geom.label(position=:right ;hide_overlaps=true))[1])
end
if (showIntNodeLabel)
push!(mylayers, layer(ndf[.!ndf[:lea], [:x,:y,:name]], y="y", x="x", label="name",
push!(mylayers, layer(ndf[.!ndf[!,:lea], [:x,:y,:name]], y="y", x="x", label="name",
Geom.label(position=:above ;hide_overlaps=true))[1])
end
if (showNodeNumber)
push!(mylayers, layer(ndf, y="y", x="x", label="num",
Geom.label(position=:dynamic ;hide_overlaps=true))[1])
end
if labelnodes
push!(mylayers, layer(ndf[[:x,:y,:lab]], y="y", x="x", label="lab",
push!(mylayers, layer(ndf[!,[:x,:y,:lab]], y="y", x="x", label="lab",
Geom.label(position=:left ;hide_overlaps=false))[1])
end
end
# data frame for edge annotations.
labeledges, edf = prepareEdgeDataFrame(net, edgeLabel, mainTree,
edge_xB, edge_xE, edge_yB, edge_yE)
if labeledges
push!(mylayers, layer(edf[[:x,:y,:lab]], y="y", x="x", label="lab",
push!(mylayers, layer(edf[!,[:x,:y,:lab]], y="y", x="x", label="lab",
Geom.label(position=:above ;hide_overlaps=false))[1])
end
if (showEdgeLength)
push!(mylayers, layer(edf[[:x,:y,:len]], y="y", x="x", label="len",
push!(mylayers, layer(edf[!,[:x,:y,:len]], y="y", x="x", label="len",
Geom.label(position=:below ;hide_overlaps=false))[1])
end
if (showGamma && net.numHybrids>0)
if !mainTree
push!(mylayers, layer(edf[edf[:hyb] .& edf[:min], [:x,:y,:gam]], y="y", x="x",label="gam",
push!(mylayers, layer(edf[edf[!,:hyb] .& edf[!,:min], [:x,:y,:gam]], y="y", x="x",label="gam",
Geom.label(position=:below ;hide_overlaps=true),
Theme(point_label_color=minorHybridEdgeColor))[1])
end
push!(mylayers, layer(edf[edf[:hyb] .& .!edf[:min],[:x,:y,:gam]], y="y", x="x",label="gam",
push!(mylayers, layer(edf[edf[!,:hyb] .& .!edf[!,:min], [:x,:y,:gam]], y="y", x="x",label="gam",
Geom.label(position=:below ;hide_overlaps=true),
Theme(point_label_color=majorHybridEdgeColor))[1])
end
if (showEdgeNumber)
push!(mylayers, layer(edf[[:x,:y,:num]], y="y", x="x", label="num",
push!(mylayers, layer(edf[!,[:x,:y,:num]], y="y", x="x", label="num",
Geom.label(position=:dynamic ;hide_overlaps=false))[1])
end

Expand Down
49 changes: 16 additions & 33 deletions src/plotRCall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ optional arguments, shared with the Gadfly-based plot function:
- minorHybridEdgeColor: color for minor hybrid edges
- showEdgeNumber: if true, edges are labelled with the number used internally.
- showIntNodeLabel: if true, internal nodes are labelled with their names.
Useful for hybrid nodes, which do have tags like '#H1'.
Useful for hybrid nodes, which do have tags like 'H1'.
- edgeLabel: dataframe with two columns: the first with edge numbers, the second with labels
(like bootstrap values) to annotate edges. empty by default.
- nodeLabel: dataframe with two columns: the first with node numbers, the second with labels
Expand Down Expand Up @@ -81,55 +81,38 @@ function plot(net::HybridNetwork, method::Symbol; useEdgeLength=false::Bool,
segments($edge_xB, $edge_yB, $edge_xE, $edge_yE, col=$eCol)
segments($node_x, $node_yB, $node_x, $node_yE, col=$edgeColor)
"""
@rput tipcex
if showTipLabel
R"""
text($(node_x[leaves])+$tipOffset, $(node_y[leaves]),
$(tipLabels(net)), adj=0, font=3, cex=tipcex)
"""
R"text"(node_x[leaves] .+ tipOffset, node_y[leaves],
tipLabels(net), adj=0, font=3, cex=tipcex)
end
if showIntNodeLabel
R"""
text($(ndf[.!ndf[:lea],:x]), $(ndf[.!ndf[:lea],:y]),
$(ndf[.!ndf[:lea],:name]), adj=c(.5,0))
"""
R"text"(ndf[.!ndf[!,:lea],:x], ndf[.!ndf[!,:lea],:y],
ndf[.!ndf[!,:lea],:name], adj=[.5,0])
end
if showNodeNumber
R"""
text($(ndf[:x]), $(ndf[:y]), $(ndf[:num]), adj=1)
"""
R"text"(ndf[!,:x], ndf[!,:y], ndf[!,:num], adj=1)
end
if labelnodes
R"""
text($(ndf[:x]), $(ndf[:y]), $(ndf[:lab]), adj=1)
"""
R"text"(ndf[!,:x], ndf[!,:y], ndf[!,:lab], adj=1)
end
labeledges, edf = prepareEdgeDataFrame(net, edgeLabel, mainTree,
edge_xB, edge_xE, edge_yB, edge_yE)
if labeledges
R"""
text($(edf[:x]), $(edf[:y]), $(edf[:lab]), adj=c(.5,0))
"""
R"text"(edf[!,:x], edf[!,:y], edf[!,:lab], adj=[.5,0])
end
if showEdgeLength
R"""
text($(edf[:x]), $(edf[:y]), $(edf[:len]), adj=c(.5,1))
"""
R"text"(edf[!,:x], edf[!,:y], edf[!,:len], adj=[.5,1.])
end
if (showGamma && net.numHybrids>0)
im = edf[:hyb] .& edf[:min]
iM = edf[:hyb] .& .!edf[:min]
R"""
text($(edf[im,:x]), $(edf[im,:y]),$(edf[im,:gam]),
adj=c(.5,1), col=$minorHybridEdgeColor)
text($(edf[iM,:x]), $(edf[iM,:y]),$(edf[iM,:gam]),
adj=c(.5,1), col=$majorHybridEdgeColor)
"""
im = edf[!,:hyb] .& edf[!,:min]
iM = edf[!,:hyb] .& .!edf[!,:min]
R"text"(edf[im,:x], edf[im,:y], edf[im,:gam],
adj=[.5,1], col=minorHybridEdgeColor)
R"text"(edf[iM,:x], edf[iM,:y], edf[iM,:gam],
adj=[.5,1], col=majorHybridEdgeColor)
end
if showEdgeNumber
R"""
text($(edf[:x]), $(edf[:y]), $(edf[:num]), adj=c(.5,0))
"""
R"text"(edf[!,:x], edf[!,:y], edf[!,:num], adj=[.5,0])
end
return (xmin, xmax, ymin, ymax, node_x, node_y, node_yB, node_yE,
edge_xB, edge_xE, edge_yB, edge_yE, ndf, edf)
Expand Down
2 changes: 1 addition & 1 deletion test/test_phylonetworkPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
1., 5.,1., 4.)
dat = DataFrame(node=[-5,-3,-4,5,100],bs=["90","95","99","mytip","bogus"],edge=[8,9,4,6,200]);
@test_logs (:warn, "Some node numbers in the nodeLabel data frame are not found in the network:\n 100") PhyloPlots.checkNodeDataFrame(net, dat);
@test_logs (:warn, "nodeLabel should have 2+ columns, the first one giving the node numbers (Integer)") PhyloPlots.checkNodeDataFrame(net, dat[2:3])
@test_logs (:warn, "nodeLabel should have 2+ columns, the first one giving the node numbers (Integer)") PhyloPlots.checkNodeDataFrame(net, dat[!,2:3])
dat = DataFrame(node=[-5,-3,missing,5],
bs=["90","95","99","mytip"],edge=[8,9,4,6]);
@test PhyloPlots.checkNodeDataFrame(net, dat) == (true,
Expand Down
2 changes: 1 addition & 1 deletion test/test_plotRCall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
majorHybridEdgeColor="tan");
dat = DataFrame(node=[-5,-10,-1],bs=["90","95","100"],edge=[11,22,26]);
@test_logs (:warn, "Some node numbers in the nodeLabel data frame are not found in the network:\n -1") plot(net,:RCall, nodeLabel=dat);
@test_logs plot(net,:RCall, edgeLabel=dat[[:edge,:bs]]);
@test_logs plot(net,:RCall, edgeLabel=dat[!,[:edge,:bs]]);

# plot based on RCall and ape:
tre = readTopology("(((((((1,2),3),4),5),(6,7)),(8,9)),10);");
Expand Down

2 comments on commit 80c0ce6

@cecileane
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • new indexing rules from DataFrames v0.19
  • minor improvements

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/2849

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" 80c0ce642d48357d6a37eb21ebc98641f59fab1a
git push origin v0.2.1

Please sign in to comment.