Skip to content

phyloclim help

8 messages · Brent Hendrixson, David Winsemius

#
Hi all ?

I am a newbie to R and have had a terrible time trying to figure out how to set up an analysis.? I have installed and loaded the appropriate package (phyloclim), but I do not even know where to begin defining one of the arguments.

The usage for the command I?m trying to perform is: 

niche.equivalency.test(spec, n, maxent, mx = 2000)

where the argument?

maxent???? is a list containing the location of the MAXENT application and its input files (see below)
app????????????? the path to the MAXENT application (MAXENT is a JAVA program)

samples ???????? the path to a SWD-formatted file with sample points (e.g., samples.csv)

background ????? the path to a SWD-formatted file with background points (e.g., background.csv)

projections????? the path to a folder containing environmental GIS layers to be used for projection of the MAXENT models


Suppose all of these files are placed into the directory ?C:\Users\hendrb\Desktop\Niche_Overlap?.? Can anyone show me the syntax for
setting up the maxent argument?

I sincerely appreciate any help you can provide.

Regards,

Brent
#
Hi all ?

My apologies if this is a redundant message.? I am a newbie to R and have had a terrible time trying to figure out how to set up an analysis.  I have installed and loaded the appropriate package (phyloclim), but I'm not sure I have defined the arguments correctly.

The usage for the command I?m trying to perform is:

niche.equivalency.test(spec, n, maxent, mx = 2000)

I am comfortable with the arguments "spec", "n", and "mx" but have had problems with "maxent"

maxent????     is a list containing the location of the MAXENT application and its input files (see below)
app?????????              the path to the MAXENT application (MAXENT is a JAVA program)

samples?????          the path to a SWD-formatted file with sample points (e.g., samples.csv)

background??       the path to a SWD-formatted file with background points (e.g., background.csv)

projections?      the path to a folder containing environmental GIS layers to be used for projection of the MAXENT models

Suppose all of these files are placed into the directory ?C:\Documents and Settings\hendrb\Desktop\R?. ? Can anyone determine if I'm on the right track with the following syntax or am I way off?
When I try to execute the command niche.equivalency.test based on the above information, I get the following statement:
Error in read.table(file = file, header = header, sep = sep, quote = quote,? : 
? 'file' must be a character string or connection

I'm incredibly confused by all of this and sincerely appreciate any help you can provide.

Regards,

Brent
#
On Jun 13, 2012, at 6:29 PM, Brent Hendrixson wrote:

            
You might give the name of the package. (I'm not likely to have any  
experience with that package, but it might ring a bell so someone with  
the right background.)
Right. So what is the object named "spec"? The R interpreter is  
expecting a file name or a connection object.
David Winsemius, MD
West Hartford, CT
#
Hi David -

Thanks for the response.
The package is "phyloclim" (evolutionary biology).
?
The object "spec" is a vector of mode = character and length = 2 (it contains the names of two different species that I'm comparing).? I did define it correctly (to my knowledge).? It looks like:

spec <- c("aphonopelma_mojave", "aphonopelma_newmojave")

I'm just unsure if everything else for the "maxent" argument is defined correctly and whether I have set up the list appropriately.? If the syntax is okay, then I just need to check the files.? Unfortunately, the error message does not indicate which file is throwing stuff off...

Thanks again!


?
#
On Jun 13, 2012, at 11:00 PM, Brent Hendrixson wrote:

            
The error message made clear that someplace along the line there was a  
missing argument to the read.table function.
Looking at the package documentation I see this:

maxent:  A list containing the location of the MAXENT application and  
its input ?les (see
details).

Maybe I was wrong about 'spec' and the malformed argument is 'maxent'.  
If I had been constructing it I would have created a _named_ list:

maxent <- list( app =app,
              samples =samples,
              background,   # cannot tell if a csv file meets the  
requiremtn
#                           "The path to a SWD-formatted ?le with  
background points."
              projections =projections)  # that value .../R  looks  
pretty suspicious, too.
1 day later
#
Hi David -
Your advice definitely helped - THANK YOU!? However, I'm now getting another error that seems to be tied to the maxent java program itself.? Here's the syntax I have used for the niche.equivalency.test (recall that it consists of 4 elements: spec, n, maxent, mx=2000)

spec <- c("aphonopelma_mojave", "aphonopelma_newmojave")

app <- file.path("C:\\Documents and Settings\\hendrb\\Desktop\\R\\maxent.jar")

samples <- file.path("C:\\Documents and Settings\\hendrb\\Desktop\\R\\samples.csv")

background <- file.path("C:\\Documents and Settings\\hendrb\\Desktop\\R\\background.csv")

projections <- file.path("C:\\Documents and Settings\\hendrb\\Desktop\\R")

maxent <- list(app=app, samples=samples, background=background, projections=projections)

After I defined each of those, I tried to execute the command as follows:

niche.equivalency.test(spec, n=100, maxent, mx=2000)

And here was the message I received:

Unable to access jarfile C:\Documents
Error in file(file, "r") : cannot open the connection
In addition: Warning messages:
1: running command 'java -mx2000m -jar C:\Documents and Settings\hendrb\Desktop\R\maxent.jar -e R.phyloclim.temp/background.csv -s R.phyloclim.temp/samples.csv -j C:\Documents and Settings\hendrb\Desktop\R -o R.phyloclim.temp/out -r removeduplicates nopictures outputformat=raw autorun' had status 1 
2: In file(file, "r") :
? cannot open file 'aphonopelma_mojave_C:\Documents and Settings\hendrb\Desktop\R.asc': Invalid argument

Like I mentioned, it seems that this particular error is unrelated to R code but I'm unsure why the jarfile (maxent.jar) cannot be accessed.? 

Any thoughts?

The above command did produce a new file that serves as the input for the jarfile.

Thanks again for your help!

Brent
#
On Jun 15, 2012, at 3:43 PM, Brent Hendrixson wrote:

            
That hanging "Documents" being listed as the file target makes me  
think that the file specification is creating errors due to spaces in  
Windows directories. In Windows it is often the case that backslashes  
need to be doubled or replaced with forward slashes.I see that you  
already know that, but would have tried the forward slash gambit as  
well. (I am not sure why you are passing hte results of file.path(...)  
when you already have a complete file name. I would also try just  
giving it a file specification with just a character argument.)
David Winsemius, MD
West Hartford, CT
#
David -

You have been a tremendous help.? This solved my problems.? It's working now!? 

I switched to forward slashes and changed the directory to "C:/R".? I tweaked the memory available to maxent and VOILA!

Thank you!!! 

----------------------------------------