ERROR: UndefVarError: `writeTableCF` not defined in `Main`

101 views
Skip to first unread message

Wyclif Odago

unread,
Feb 13, 2025, 5:46:22 AMFeb 13
to PhyloNetworks users
Hi, I am trying to generate a table but I keep getting this error. 
julia> # Convert to DataFrame and save

julia> df = writeTableCF(q, t)  # Requires PhyloNetworks v2.0+
ERROR: UndefVarError: `writeTableCF` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] top-level scope

This is my full code but the error only comes at DataFrame"using PhyloNetworks, CSV, DataFrames

# ---------------------------
# Step 1: Read Input Data
# ---------------------------
# Read gene trees (RAxML bootstraps or best trees)
genetrees = readMultiTopology("D:/Project/2025 study/Results/plastomes/aligned/ASTRAL/species2_tree.tre")

# ---------------------------
# Step 2: Calculate Concordance Factors (CFs)
# ---------------------------
q, t = countquartetsintrees(genetrees)
df = writeTableCF(q, t)
CSV.write("D:/Project/2025 study/Results/CF_table.csv", DataFrames.describe(df)  # Save CF table

# ---------------------------
# Step 3: Read Species Tree & Run SNaQ
# ---------------------------
astraltree = readTopology("D:/Project/2025 study/Results/plastomes/aligned/ASTRAL/species3_tree.tre")
raxmlCF = readTableCF("D:/Project/2025 study/Results/CF_table.csv")

# Run SNaQ (allow 1 hybridization with hmax=1)
net0 = snaq!(
    astraltree,
    hmax = 1,              # Allow 1 hybridization event
    filename = "D:/Project/2025 study/Results/net0",
    seed = 3456,
    runs = 100
)"
How can I solve this?

cheers,
Wyclif

Cécile Ané

unread,
Feb 13, 2025, 9:27:52 AMFeb 13
to PhyloNetworks users
Which version of PhyloNetworks (and other packages) are you using? You can tell by running the commands:

using Pkg
Pkg.status()

Looking at your code, you should use PhyloNetworks v0.16. So if you are using a newer version, you can go back to v0.16 of PhyloNetworks like this:

Pkg.pin(name="PhyloNetworks", version="0.16.4")

I hope it helps.
The current version of PhyloNetworks (v1.0.0) does not have SNaQ, because this method is in the process of being transferred into a dedicated package SNaQ.jl. (with improvements coming next!)
Cecile.


Jenna Mccullough

unread,
Feb 14, 2025, 2:12:38 PMFeb 14
to PhyloNetworks users
Hi,

I also have this problem but your suggestion did not work for me. 

I have version 1.0.0 of PhyloNetworks

When I tried what you suggested with Pkg.pin in your above answer, it did not work: 
julia>Pkg.pin(name="PhyloNetworks",version="0.16.4") 
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package PhyloPlots [c0d5b6db]:
 PhyloPlots [c0d5b6db] log:
 ├─possible versions are: 0.2.0 - 2.0.1 or uninstalled
 ├─restricted to versions * by project [eaa55427], leaving only versions: 0.2.0 - 2.0.1
 │ └─project [eaa55427] log:
 │   ├─possible versions are: 0.0.0 or uninstalled
 │   └─project [eaa55427] is fixed to version 0.0.0
 ├─restricted to versions 2.0.1 by an explicit requirement, leaving only versions: 2.0.1
 └─restricted by compatibility requirements with PhyloNetworks [33ad39ac] to versions: 0.3.2 - 1.0.1 or uninstalled — no versions left
   └─PhyloNetworks [33ad39ac] log:
     ├─possible versions are: 0.9.0 - 1.0.0 or uninstalled
     ├─restricted to versions * by project [eaa55427], leaving only versions: 0.9.0 - 1.0.0
     │ └─project [eaa55427] log: see above
     └─restricted to versions 0.16.4 by an explicit requirement, leaving only versions: 0.16.4
Stacktrace:
  [1] propagate_constraints!(graph::Pkg.Resolve.Graph, sources::Set{Int64}; log_events::Bool)
    @ Pkg.Resolve ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Resolve/graphtype.jl:1072
  [2] propagate_constraints! (repeats 2 times)
    @ ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Resolve/graphtype.jl:1008 [inlined]
  [3] simplify_graph!(graph::Pkg.Resolve.Graph, sources::Set{Int64}; clean_graph::Bool)
    @ Pkg.Resolve ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Resolve/graphtype.jl:1533
  [4] simplify_graph! (repeats 2 times)
    @ ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Resolve/graphtype.jl:1532 [inlined]
  [5] resolve_versions!(env::Pkg.Types.EnvCache, registries::Vector{…}, pkgs::Vector{…}, julia_version::VersionNumber, installed_only::Bool)
    @ Pkg.Operations ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Operations.jl:430
  [6] targeted_resolve(env::Pkg.Types.EnvCache, registries::Vector{…}, pkgs::Vector{…}, preserve::Pkg.Types.PreserveLevel, julia_version::VersionNumber)
    @ Pkg.Operations ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Operations.jl:1398
  [7] tiered_resolve(env::Pkg.Types.EnvCache, registries::Vector{…}, pkgs::Vector{…}, julia_version::VersionNumber, try_all_installed::Bool)
    @ Pkg.Operations ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Operations.jl:1387
  [8] _resolve(io::IOContext{…}, env::Pkg.Types.EnvCache, registries::Vector{…}, pkgs::Vector{…}, preserve::Pkg.Types.PreserveLevel, julia_version::VersionNumber)
    @ Pkg.Operations ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Operations.jl:1408
  [9] pin(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.Operations ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/Operations.jl:1675
 [10] pin(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; all_pkgs::Bool, kwargs::@Kwargs{io::IOContext{IO}})
    @ Pkg.API ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/API.jl:429
 [11] pin(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{IO}, kwargs::@Kwargs{})
    @ Pkg.API ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/API.jl:159
 [12] pin(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API ~/Dropbox/School_Research/Publications/2024_McCullough_Todiramphus-genomes/Todiramphus-WGS-SystBiol/01_analysis/04_UCE-analyses/07_SNaQ/julia-1.11.3/share/julia/stdlib/v1.11/Pkg/src/API.jl:148
 [13] pin(; name::String, uuid::Nothing, version::String, url::Nothing, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::@Kwargs{})
    @ Pkg.API ./array.jl:0
 [14] top-level scope
    @ REPL[17]:1
Some type information was truncated. Use `show(err)` to see complete types.




I downloaded the SNaQ.jl package using this command: 
its the version 0.1.0 

but the ability to load a CF table or even run SNaQ does not work: 
julia>todiCF = readTableCF("tableCF-4845quart.csv")
ERROR: UndefVarError: `readTableCF` not defined in `Main`

Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] top-level scope
   @ REPL[10]:1

I can get it imported as a .csv file: 
julia>todiCF = CSV.File("tableCF-4845quart.csv")

but this does not work either: 
julia>net0 = SNaQ(tre, todiCF, hmax=0, runs=10, filename="net0_snaq", seed=456)
ERROR: MethodError: objects of type Module are not callable
The object of type `Module` exists, but no method is defined for this combination of argument types when trying to treat it as a callable object.
Stacktrace:
 [1] top-level scope
   @ REPL[13]:1

Thanks in advance

Jenna 

Cécile Ané

unread,
Feb 14, 2025, 2:58:44 PMFeb 14
to PhyloNetworks users
Ah, the error says that it's because your environment requires PhyloPlots 2.0.1, which is not compatible with the earlier PhyloNetworks v0.16. You can fix this by removing PhyloPlots, downgrading PhyloNetworks, then adding again PhyloPlots, without requiring a specific version --or pinned at v1.0.1, which is compatible with the earlier version of PhyloNetworks. So like this:

using Pkg
Pkg.rm("PhyloPlots")
Pkg.pin(name="PhyloNetworks", version="0.16.4")
Pkg.add("PhyloPlots")
# or:
Pkg.pin(name="PhyloPlots", version="1.0.1")

SNaQ.jl is not ready yet. When it's ready, it will be v1.0.0 and it will be officially registered. There will be no need to refer to it by its url.
So for now, to run the SNaQ method, we all still need to use PhyloNetworks v0.16.

Next time, don't hesitate to give the output of Pkg.status(), because it is very helpful to understand which package may be restricting the versions of other packages.
Cheers,
Cecile.

Jenna Mccullough

unread,
Feb 14, 2025, 3:31:00 PMFeb 14
to Cécile Ané, PhyloNetworks users
Hi Cecile, 

 Yes, that worked. I will use what you suggested in the future! 

Thank you again 

Jenna 



--
You received this message because you are subscribed to a topic in the Google Groups "PhyloNetworks users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phylonetworks-users/sNxwXxhmDb4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phylonetworks-u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/phylonetworks-users/ca1e7c27-bba1-43a6-870e-7cc5c65b4b2en%40googlegroups.com.

huan shu

unread,
Jun 17, 2025, 4:04:23 AMJun 17
to JuliaPhylo users
Hi,Ihave the same problem,and tried  Cecile's method,but it's keeping report errors.
julia> df = writeTableCF(q,t)

ERROR: UndefVarError: `writeTableCF` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] top-level scope
   @ REPL[48]:1

julia> Pkg.status()
Status `~/.julia/environments/v1.11/Project.toml`
  [336ed68f] CSV v0.10.15
⌃ [33ad39ac] PhyloNetworks v0.16.4
⌃ [c0d5b6db] PhyloPlots v1.0.1 ⚲
  [6f49c342] RCall v0.14.8
Info Packages marked with ⌃ have new versions available and may be upgradable.
Could you help me ,please?

Cécile Ané

unread,
Jun 17, 2025, 5:22:20 PMJun 17
to JuliaPhylo users
Try this in package mode (type ] to switch to package mode), to update to the most recent package versions:

rm PhyloPlots
update
add PhyloPlots
add SNaQ

Then follow the documentation for SNaQ (here: https://juliaphylo.github.io/SNaQ.jl/stable/), which is now officially released, currently at version v1.0.0.
Note that several functions have been renamed.
For example, writeTableCF does not exists in the updated package. Instead, use tablequartetCF.

Follow the documentation that corresponds to the package version that you are currently using. In the online documentation, you can switch from one version to another by clicking on the version number in the lower-left corner.
Reply all
Reply to author
Forward
0 new messages