@@ -162,28 +162,28 @@ end
162
162
163
163
function readTableCF! (df:: DataFrames.DataFrame ; summaryfile= " " :: AbstractString , kwargs... )
164
164
@debug " assume the numbers for the taxon read from the observed CF table match the numbers given to the taxon when creating the object network"
165
+ taxoncolnames = [[:t1 , :tx1 , :tax1 , :taxon1 ], [:t2 , :tx2 , :tax2 , :taxon2 ],
166
+ [:t3 , :tx3 , :tax3 , :taxon3 ], [:t4 , :tx4 , :tax4 , :taxon4 ] ]
167
+ taxoncol = [findfirst (x-> x ∈ taxoncolnames[1 ], DataFrames. propertynames (df)),
168
+ findfirst (x-> x ∈ taxoncolnames[2 ], DataFrames. propertynames (df)),
169
+ findfirst (x-> x ∈ taxoncolnames[3 ], DataFrames. propertynames (df)),
170
+ findfirst (x-> x ∈ taxoncolnames[4 ], DataFrames. propertynames (df))]
165
171
alternativecolnames = [ # obsCF12 is as exported by fittedQuartetCF()
166
- [:CF12_34 , Symbol (" CF12.34" ), :obsCF12 ],
167
- [:CF13_24 , Symbol (" CF13.24" ), :obsCF13 ],
168
- [:CF14_23 , Symbol (" CF14.23" ), :obsCF14 ]
172
+ [:CF12_34 , Symbol (" CF12.34" ), :obsCF12 , :CF1234 ],
173
+ [:CF13_24 , Symbol (" CF13.24" ), :obsCF13 , :CF1324 ],
174
+ [:CF14_23 , Symbol (" CF14.23" ), :obsCF14 , :CF1423 ]
169
175
]
170
176
obsCFcol = [findfirst (x-> x ∈ alternativecolnames[1 ], DataFrames. propertynames (df)),
171
177
findfirst (x-> x ∈ alternativecolnames[2 ], DataFrames. propertynames (df)),
172
178
findfirst (x-> x ∈ alternativecolnames[3 ], DataFrames. propertynames (df))]
173
179
ngenecol = findfirst (isequal (:ngenes ), DataFrames. propertynames (df))
174
180
withngenes = ngenecol != = nothing
175
- if nothing in obsCFcol # one or more col names for CFs were not found
176
- size (df,2 ) == (withngenes ? 8 : 7 ) ||
177
- @warn """ Column names for quartet concordance factors (CFs) were not recognized.
178
- Was expecting CF12_34, CF13_24 and CF14_23 for the columns with CF values,
179
- or CF12.34 or obsCF12, etc.
180
- Will assume that the first 4 columns give the taxon names, and that columns 5-7 give the CFs."""
181
- obsCFcol = [5 ,6 ,7 ] # assuming CFs are in columns 5,6,7, with colname mismatch
182
- end
183
- minimum (obsCFcol) > 4 ||
184
- error (" CFs found in columns $obsCFcol , but taxon labels expected in columns 1-4" )
185
- # fixit: what about columns giving the taxon names: always assumed to be columns 1-4? No warning if not?
186
- columns = [[1 ,2 ,3 ,4 ]; obsCFcol]
181
+ nothing in taxoncol && error (" columns for taxon names were not found" )
182
+ nothing in obsCFcol && error (
183
+ """ Could not identify columns with quartet concordance factors (qCFs).
184
+ Was expecting CF12_34, CF13_24 and CF14_23 for the columns with CF values,
185
+ or CF12.34 or obsCF12, etc.""" )
186
+ columns = [taxoncol; obsCFcol]
187
187
if withngenes push! (columns, ngenecol) end
188
188
189
189
d = readTableCF! (df, columns; kwargs... )
@@ -661,15 +661,16 @@ data: [1.0, 0.0, 0.0, 0.5]
661
661
julia> df = writeTableCF(q,t); # to get a DataFrame that can be saved to a file later
662
662
663
663
julia> show(df, allcols=true)
664
- 5×8 DataFrame
665
- Row │ t1 t2 t3 t4 CF12_34 CF13_24 CF14_23 ngenes
666
- │ String String String String Float64 Float64 Float64 Float64
667
- ─────┼────────────────────────────────────────────────────────────────────
668
- 1 │ A B D E 0.25 0.25 0.5 2.0
669
- 2 │ A B D O 0.5 0.5 0.0 1.0
670
- 3 │ A B E O 1.0 0.0 0.0 0.5
671
- 4 │ A D E O 1.0 0.0 0.0 0.5
672
- 5 │ B D E O 0.0 0.0 0.0 0.0
664
+ 5×9 DataFrame
665
+ Row │ qind t1 t2 t3 t4 CF12_34 CF13_24 CF14_23 ngenes
666
+ │ Int64 String String String String Float64 Float64 Float64 Float64
667
+ ─────┼───────────────────────────────────────────────────────────────────────────
668
+ 1 │ 1 A B D E 0.25 0.25 0.5 2.0
669
+ 2 │ 2 A B D O 0.5 0.5 0.0 1.0
670
+ 3 │ 3 A B E O 1.0 0.0 0.0 0.5
671
+ 4 │ 4 A D E O 1.0 0.0 0.0 0.5
672
+ 5 │ 5 B D E O 0.0 0.0 0.0 0.0
673
+
673
674
julia> # using CSV; CSV.write(df, "filename.csv");
674
675
675
676
julia> tree2 = readTopology("((A,(B,D)),E);");
@@ -680,15 +681,15 @@ Reading in trees, looking at 5 quartets in each...
680
681
**
681
682
682
683
julia> show(writeTableCF(q,t), allcols=true)
683
- 5×8 DataFrame
684
- Row │ t1 t2 t3 t4 CF12_34 CF13_24 CF14_23 ngenes
685
- │ String String String String Float64 Float64 Float64 Float64
686
- ─────┼───────────────────────────────────────────────────────────────────────
687
- 1 │ A B D E 0.333333 0.333333 0.333333 3.0
688
- 2 │ A B D O 0.5 0.5 0.0 2.0
689
- 3 │ A B E O 1.0 0.0 0.0 1.0
690
- 4 │ A D E O 1.0 0.0 0.0 1.0
691
- 5 │ B D E O 0.0 0.0 0.0 0.0
684
+ 5×9 DataFrame
685
+ Row │ qind t1 t2 t3 t4 CF12_34 CF13_24 CF14_23 ngenes
686
+ │ Int64 String String String String Float64 Float64 Float64 Float64
687
+ ─────┼──────────────────────────────────────────────────────────────────────────────
688
+ 1 │ 1 A B D E 0.333333 0.333333 0.333333 3.0
689
+ 2 │ 2 A B D O 0.5 0.5 0.0 2.0
690
+ 3 │ 3 A B E O 1.0 0.0 0.0 1.0
691
+ 4 │ 4 A D E O 1.0 0.0 0.0 1.0
692
+ 5 │ 5 B D E O 0.0 0.0 0.0 0.0
692
693
```
693
694
"""
694
695
function countquartetsintrees (tree:: Vector{HybridNetwork} ,
0 commit comments