Learn R Programming

BioGeoBEARS (version 0.2.1)

save_tipranges_to_LagrangePHYLIP: Save a tipranges object to a LAGRANGE PHYLIP-style file containing binary-encoded geographic ranges

Description

Given some geographic range data for tips in the tipranges object, this function exports them to an ASCII text file in the Lagrange C++/PHYLIP format (Smith et al. (2010)). This file can then be read by getranges_from_LagrangePHYLIP.

Usage

save_tipranges_to_LagrangePHYLIP(tipranges_object, lgdata_fn = "lagrange_area_data_file.data", areanames = colnames(tipranges_object@df))

Arguments

tipranges_object
An object of class tipranges.
lgdata_fn
The LAGRANGE geographic data file to be output.
areanames
A list of the names of the areas.

Value

tipranges_object An object of class tipranges

Details

LAGRANGE C++ geographic range files are ASCII text files with the format:

19 4 (A B C D) P_mariniana_Kokee2 1000 P_mariniana_Oahu 0100 P_mariniana_MauiNui 0010 P_hawaiiensis_Makaopuhi 0001 P_wawraeDL7428 1000 [...]

The first row specifies the number of taxa (here, 19), the number of areas (here, 4), and finally, the names/abbreviations of the areas. The rest of the rows give the taxon names, followed by a tab and then the presence/absence in each range with 1s/0s.

The file above is part of the geographic range data for the Hawaiian Psychotria dataset used by Ree et al. (2008).

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster https://code.google.com/p/lagrange/

SmithRee2010_CPPversion

ReeSmith2008

Matzke_2012_IBS

See Also

define_tipranges_object, getranges_from_LagrangePHYLIP

Examples

Run this code
testval=1

# Create an example tipranges object
tipranges = define_tipranges_object()

# See current directory
getwd()

## Not run: 
# # Save the file
# # Set the filename
# fn = "example_tipranges.data"
# save_tipranges_to_LagrangePHYLIP(tipranges_object=tipranges, lgdata_fn=fn)
# 
# # Show the file
# tmplines = scan(file=fn, what="character", sep="\n")
# cat(tmplines, sep="\n")
# 
# # Again, with areanames
# save_tipranges_to_LagrangePHYLIP(tipranges_object=tipranges,
# lgdata_fn=fn, areanames=c("area1","area2","area3"))
# 
# # Show the file
# tmplines = scan(file=fn, what="character", sep="\n")
# cat(tmplines, sep="\n")
# ## End(Not run) # End dontrun

Run the code above in your browser using DataLab