## One year as faculty and new website

This site has been derelict for the past year, as starting out as a new faculty at UNESP consumed all of my free time. We are now slowly transitioning to a lab webpage (https://sites.google.com/site/ecosystemobservation/), and will start blogging “for real” very soon. Stay tuned!

## Installing Slidify on a Windows Machine

I’ve been wanting to try out the amazing Slidify package developed by Ramnath Vaidyanathan for a while. What it does is generate html slide shows directly from R, using R markdown. Turns out it was the perfect entertainment for someone down with a flu on a very hot summer weekend.

I followed the instructions described here, but ran into a few problems. Google-fu only gave me one closed discussion thread with someone else having the same problem, which was solved by upadting to R 2.15.2.

Since I was already on R 2.15.2, that wasn’t much help. But, as Ramnath mentioned in that thread, it’s mostly a problem with install_github, and building it from source worked for me. So, if you have never built an R package from source (like I didn’t), this post will hopefully save you a few hours.

### Step 0: My session info, just for reference

> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] devtools_1.1

loaded via a namespace (and not attached):
[1] digest_0.6.0    evaluate_0.4.2  httr_0.2        memoise_0.1     parallel_2.15.2 plyr_1.7.1
[7] RCurl_1.95-3    stringr_0.6.1   tools_2.15.2    whisker_0.1

Library path is C:/Users/Thiago Silva/Documents/R/win-library/2.15


I grabbed it from here, Version 3.0, ran the executable, no hassle.

### Step 2: Install devtools

At the R command prompt:

install.packages('devtools')


No hassle either.

### Step 3: Install slidify from Github, using devtools

As suggested on Ramnath’s page, all smooth.

install_github("slidify", "ramnathv")


### Step 4: Install slidifyLibraries

This is where the problems began. Using the recommended install_github method gave me the following error:

> install_github("slidifyLibraries", "ramnathv")
Installing github repo(s) slidifyLibraries/master from ramnathv
Installing slidifyLibraries.zip from https://github.com/ramnathv/slidifyLibraries/archive/master.zip
Installing slidifyLibraries
"C:/PROGRA~1/R/R-215~1.2/bin/x64/R" --vanilla CMD build "C:\Users\Thiago  \
Silva\AppData\Local\Temp\Rtmp8esQJH\slidifyLibraries-master" --no-manual --no-resave-data

* checking for file 'C:\Users\Thiago Silva\AppData\Local\Temp\Rtmp8esQJH\slidifyLibraries-master/DESCRIPTION' ... OK
* preparing 'slidifyLibraries':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'slidifyLibraries_0.1.tar.gz'

Warning in utils::tar(filepath, pkgname, compression = "gzip", compression_level = 9,  :
storing paths of more than 100 bytes is not portable:
'slidifyLibraries/inst/libraries/frameworks/landslide/themes/machinalis/fonts/OFLGoudyStMTT-Italic.ttf'


(I got a lot of these warnings, only showing first and last)

Warning in utils::tar(filepath, pkgname, compression = "gzip", compression_level = 9,  :
storing paths of more than 100 bytes is not portable:
'slidifyLibraries/inst/libraries/widgets/mathjax/jax/output/SVG/fonts/TeX/Typewriter/Regular/CombDiacritMarks.js'

"C:/PROGRA~1/R/R-215~1.2/bin/x64/R" --vanilla CMD INSTALL  \
"C:\Users\THIAGO~1\AppData\Local\Temp\Rtmp8esQJH/slidifyLibraries_0.1.tar.gz"  \
--library="C:/Users/Thiago Silva/Documents/R/win-library/2.15" --with-keep.source

Warning in max(which(block[1:100] > 0)) :
no non-missing arguments to max; returning -Inf
Warning in rawToChar(block[seq_len(ns)]) : NAs introduced by coercion
Error in seq_len(ns) : argument must be coercible to non-negative integer

Error: Command failed (1)


### Step 5) Install slidifyLibraries from Windows command prompt

Since the above didn’t work, I took matters in my own hands. First, I built the package from source using devtools. I downloaded it from Ramnath’s repository as a Zip file, then extracted it and removed the “-Master” from the main folder name (no idea if renaming matters or not, to be honest).

build("C:/Users/Thiago Silva/Downloads/slidifyLibraries/", binary=FALSE)


This gave me a file named “slidifyLibraries_0.1.tar.gz”. Once I had it, I opened a command prompt window, navigated to the folder where the file was, and typed:

R CMD INSTALL slidifyLibraries -l "C:\Users\Thiago Silva\Documents\R\win-library\2.15"


Don’t forget to change the path to your own R library path! The following happened:

R CMD INSTALL slidifyLibraries -l "C:\Users\Thiago Silva\Documents\R\win-library\2.15"

* installing *source* package 'slidifyLibraries' ...
** R
** inst
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
*** arch - x64

* DONE (slidifyLibraries)


And, voilá, it worked (for me). I now have my first slidify presentation. Success!

P.S.- If your Dropbox path is different from the standard installation (mine is), publish() will throw an error:

> publish('testdeck3', host = 'dropbox') Creating slide directory at ~/Dropbox/Public/testdeck3 Copying files to ~/Dropbox/Public/testdeck3 [1] FALSE Warning messages: 1: In file.copy(".", drop_dir, overwrite = F, recursive = TRUE) : 'recursive' will be ignored as 'to' is not a single existing directory 2: In file.create(to[okay]) : cannot create file '~/Dropbox/Public/testdeck3', reason 'No such file or directory'

I fixed by creating a symbolic link to the actual Dropbox folder, inside my Documents folder, following these instructions (command-prompt option).

Posted in News | Tagged , , , , , , | 7 Comments

## No cloud effects in SAR images? Think again.

It’s usually assumed that Synthetic Aperture Radar (SAR) images can penetrate through clouds, giving you an image regardless of cloud cover conditions. Well, that’s true…most of the time. Heavy clouds can still have an effect, especially for shorter wavelengths such as X and C bands.

I was really (and nerdily) excited after looking at the image below. A big, diffuse black spot over smooth forest, that isn’t there in the images taken 23 days before or after. Granted, I’m not 100% sure it’s a cloud, but what else could it be?

If you disagree, let me know in the comments!

Clouds in a Radarsat-1 image of Curuai Lake, Amazon floodplain, Brazil. Click for larger image.

If you’re curious about where in the world is this place, look here.

Usage of the image above is granted under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unreported License.

## What’s the fastest implementation of the Mantel test in R?

I’ve been helping a friend with some spatial analyses, which include a Mantel test to evaluate spatial autocorrelation. The original vector data is aggregated into increasingly small cells, and spatial autocorrelation is tested for each grid size (to assess the effect of scale), to the point where the smallest scale will simply crash the program. So for the sake of my short patience code optimization, I have been looking at different implementations of the test in R.

So far I have found three implementations: mantel.rtest on the ade4 package, mantel on the ecodist package, and mantel on the vegan package.

Curious to see if there was any difference in processing speed,  I timed each implementation, with the same data:

> length(dst.bu04800) # first distance vector [1] 405450 

> length(dsg.bu04800) # second distance vector [1] 405450

> # using ecodist > system.time(man.bu.04800 <- mantel(dst.bu04800 ~ dsg.bu04800, nperm = 1000)) user  system elapsed 17.66    0.03   18.18

> # using ade4 > system.time(man.bu.04800 <- mantel.rtest(dst.bu04800,dsg.bu04800, nrepet = 1000)) user  system elapsed 39.33    5.99   45.71

> # using vegan > system.time(man.bu.04800 <- mantel(dst.bu04800,dsg.bu04800, permutations = 1000)) user  system elapsed 53.07    4.42   57.69

For perspective, the machine I am using is a Dell Precision T7500 with Dual 2.13 Ghz Quad Core Xeon E5506 processors , and 6GB of RAM. I’m running R 2.13.0 64-bit, on Windows 7 Ultimate 64.

I guess that ecodist it is, at least for me.

But, just so you know, distance in ecodist is way slower than using dist in the base package:

> system.time(dst.bu04800 <- distance(bu04800$TOT_BU_AR)) user system elapsed 13.49 0.02 13.51 > system.time(dst.bu04800 <- dist(bu04800$TOT_BU_AR)) user  system elapsed 0.01    0.00    0.02

If you think, for any reason, that I’m doing something wrong and there’s a faster way, let me know!

## Teaching at Camosun College

I’m happy to be teaching the GEOG210 course (Airphoto and Map Interpretation) at Camosun College, Victoria, BC this semester. Looking forward to the smaller class sizes and more one-to-one experience with the students.

## New Article Out

My newest article, “Annual Net Primary Production of Macrophytes in the Eastern Amazon Floodplain” is out, and available at http://www.bioone.org/doi/abs/10.1672/08-107.1

Abstract: Aquatic herbaceous macrophytes contribute significantly to the input carbon for the Amazon floodplain. These plants have large seasonal variations in areal coverage and high productivity. The present study estimates annual net primary production (NPP) of aquatic herbaceous macrophytes in a large lake on the eastern Amazon floodplain, assesses the sources and amount of uncertainty associated with these measures, and offers a comparison among the estimates of herbaceous macrophyte productivity in the Amazon region. Plant biomass accumulated during the rising water stage of the annual flood cycle, peaking at 2300 to 6100 g m-2 and decreasing later in the year. Annual net primary production was estimated to range from 2400 to 3500 g m-2 yr-1, with above water production between 650 and 1100 g m-2 yr-1, and below water production between 1700 and 2600 g m-2 yr-1. Echinochloa polystachya and Paspalum fasciculatum were the most productive species, followed by Paspalum repens, Hymenachne amplexicaulis, and Oryza perennis. The four main sources of uncertainty in the estimates were macrophyte taxa, location, sampling design, and lack of measurements of dead material loss.

## Oh, Statistics…

A statistician friend of mine just sent me the following quote:

To consult a statistician after an experiment is finished is often merely to ask him to conduct a post-mortem examination. He can perhaps say what the experiment died of.” (R. A. Fisher, 1938).

So true. That’s why someday I’ll find the time to get a second degree, in Stats.

Posted in Opinions | 1 Comment

I always had this thought about how nice it would be if they made a “facebook for researchers”, where you could look people up by name, research interests, etc. and then find their publications, institution and so on. This thought was in part inspired by the Lattes Platform, a system from the Brazilian National Research Council (CNPq) which stores this kind of information from Brazilian researchers, and is searchable by anyone. Lattes is especially great because most national government agencies refer to it when evaluating  fellowship and grant applications, which ensures that most profiles stay up to date.

Well, today I just found out about academia.edu, which is exactly that. The layout is great, simple and fast, and I can see the huge potential of it, once a good number of researchers is achieved. Give it a look, add yourself and find me there at http://uvic.academia.edu/ThiagoSilva. Finally, someone took the effort to bring social networking and the Web 2.0 to the world of academia!

Posted in News | | 2 Comments

## Presentation – 8th INTECOL Wetlands Conference, Cuiabá, Brazil.

I have attended will be attending the 8th INTECOL Wetlands Conference next month (July 20-25) in Cuiabá, MT, Brazil. I’ve presented a talk titled “Looking from above: Towards an integrative view of macrophyte growth and primary productivity in the Amazon floodplain”, on the Topic Group III: Ecosystem services and biodiversity, Primary production symposium. I’m including the submitted abstract below, and you can download the PDF of the presentation by clicking here.

Looking from above: Towards an integrative view of macrophyte growth and primary productivity in the Amazon floodplain.

Thiago Sanna F. Silva, Maycira M. P. F. Costa, John M. Melack

Aquatic macrophytes play important roles in the carbon budget of the Amazon floodplain due to their large coverage and high primary productivity, yet studies of macrophyte productivity in the Amazon region are few. The present study combines multi-temporal and multi-sensor satellite imagery and in situ data to develop a spatially and temporally consistent estimate of macrophyte coverage and primary production in the eastern Amazon floodplain. Field results indicate that plant biomass accumulates during rising water and reduces later in the season. Annual net primary production calculated from field data varied between 2470 and 3490 g/m2 (dry weight), with above water production between 650 and 1100 g/m2 and below water production between 1700 and 2570 g/m2. Remote sensing results indicate that within a single date, C-HV radar (ASAR) and infrared (MODIS) data have the highest potential for discriminating macrophytes from other cover types. The temporal variation in radiometric signature from macrophytes in C-HH at 35º (Radarsat) incidence angle and infrared (MODIS) differ the most from other cover classes. Further research is being conducted on the use of object-oriented segmentation/classification and spatial modeling to accurately map macrophyte cover and estimate macrophyte primary production over time, allowing for improvements in the current estimations of the contribution of macrophyte communities to the carbon budget of the Amazon floodplain.

Presentation (PDF, 3.5MB)

Posted in News | | 1 Comment

## Review Paper is Out

My review article entitled “Remote Sensing of Aquatic Vegetation: Theory and Applications” is finally out. You can access it at: