save_tipranges_to_LagrangePHYLIP: Save a tipranges object to a LAGRANGE PHYLIP-style file...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/BioGeoBEARS_basics_v1.R

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

1
2
3
  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.

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).

Value

tipranges_object An object of class tipranges

Note

Go BEARS!

Author(s)

Nicholas J. Matzke [email protected]

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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

BioGeoBEARS documentation built on May 29, 2017, 8:36 p.m.