Science and Perspective.

R Code for using functions by columns in a data set

I have information for the observers that have surveyed locations in a given habitat, and of course the species they saw and the locations they conducted the surveys at.

I am interpreting the observer as a species and their abundance is measured as the number of minutes they spend or the number of surveys they conduct. The Location is treated similarly. The species I am treating the abundance as the number of surveys they showed up in, though I could also sum the number of individuals when the count data is collected. I opted for counting the number of surveys the bird was seen in here, because not everyone counts the individuals and there is more data when you use the presence absence.

I created a function (effectivespecies) to find the effective number of equally abundant species when shannon’s diversity is calculated. basically exp(shannon’s Diversity(community)) .

I could do this,

exp(diversity(ObsMinutesInHabitat$Water))#Shannon’s diversity
exp(diversity(ObsMinutesInHabitat$Pine))#Shannon’s diversity
exp(diversity(ObsMinutesInHabitat$Wetland))#Shannon’s diversity
exp(diversity(ObsMinutesInHabitat$Sand))#Shannon’s diversity
exp(diversity(ObsMinutesInHabitat$Urban))#Shannon’s diversity
exp(diversity(ObsMinutesInHabitat$Grass))#Shannon’s diversity
exp(diversity(ObsMinutesInHabitat$HWTC))#Shannon’s diversity

WHich gives me this
> exp(diversity(ObsMinutesInHabitat$Water))#Shannon’s diversity
[1] 7.8
> exp(diversity(ObsMinutesInHabitat$Pine))#Shannon’s diversity
[1] 40
> exp(diversity(ObsMinutesInHabitat$Wetland))#Shannon’s diversity
[1] 24
> exp(diversity(ObsMinutesInHabitat$Sand))#Shannon’s diversity
[1] 26
> exp(diversity(ObsMinutesInHabitat$Urban))#Shannon’s diversity
[1] 26
> exp(diversity(ObsMinutesInHabitat$Grass))#Shannon’s diversity
[1] 32

but I instead created a function

##create effective number of species function####
effectivesps <- function(x) #This function works on a data frame x using whichever other function you select

and used colwise ##column-wise application of a function over a dataframe

> colwise(effectivesps)(ObsMinutesInHabitat[,2:8])
Water Pine Wetland Sand Urban Grass HWTC
1 7.8 40 24 26 26 32 6.4

Me Likey


Jaccard function by columns

So, really, I just wrote a function in R to apply the jaccard similarity function to all possible pairs in a series of columns from a data frame and spit out the result in a matrix. I am pretty happy with myself.
here is the function and the results so you can now know how similar the group of observers that visit different habitats on the island of Grand Bahama were between 1988 and 2016.

Jaccardcolumns <- function(x,fun)
n <- ncol(x)

foo <- matrix(0,n,n)
for ( i in 1:n)
for (j in 1:n)
foo[i,j] <- fun(x[,i],x[,j])
colnames(foo)<-rownames(foo)<-c("Water", "Pine", "Wetland", "Sand", "Urban", "Grass", "HWTC")

Jaccardcolumns(ObserverVisitedHabitat[2:8], clujaccard)

> Jaccardcolumns(ObserverVisitedHabitat[2:8], clujaccard)
Water Pine Wetland Sand Urban Grass HWTC
Water 1.000 0.084 0.076 0.058 0.071 0.048 0.036
Pine 0.084 1.000 0.336 0.354 0.400 0.330 0.245
Wetland 0.076 0.336 1.000 0.463 0.362 0.360 0.217
Sand 0.058 0.354 0.463 1.000 0.420 0.496 0.193
Urban 0.071 0.400 0.362 0.420 1.000 0.389 0.216
Grass 0.048 0.330 0.360 0.496 0.389 1.000 0.163
HWTC 0.036 0.245 0.217 0.193 0.216 0.163 1.000

Ancilleno Davis, AA; BSc; MSc
Twitter: @ancilleno
Founder/Coordinator – BEINGS
Director At Large – BirdsCaribbean

The beatings I remember (1) aka Black Beauty

So, recently, I have engaged in a few discussions on the purpose/benefit of corporal punishment. This includes, who does it, when, where, why and how they do it.

As I am raising two boys of my own, I am considering rewards, discipline and punishment and how these may work together to form a child’s (later adult) perception of morality and law. To that end, I am revisiting some of the most memorable beatings (cuthip, cutass, whooping, whippings, canings, cutskins etc.).

I am sharing these here, because it may be useful to those of you implementing to see what the perception is later on. I am also not going to put them all up one time, so bear with me. (the previous paragraphs are your trigger warnings)

Black Beauty

The dean of students at the highschool I attended had a cane called “black beauty” that would accompany him when he came to speak to classes and sat leaning against his desk where he would conduct interviews of the students who would potentially be on the receiving end. sometimes, the line would be out the door for students that were late on a particular day or sent to his office for a skirt that was too short, hair that was too long, an earring on a boy or more than two earrings on a girl, etc. I had been part of that line on multiple occasions, and I watched boys and girls in front of me get caned. I never got that public caning (that I remember), but that is the thing about a beating, the butt has a very short memory.

On campus, I never met the dean until 8th grade, but I met him before and whether or not he remembers, I do. We were at a party for some of my younger brother’s classmates. I believe it was aa birthday party. I had to go, but did not know anyone, so I sat watching the younger kids. I was about to enter into highschool (7th grade in the Bahamas). I was sitting between my father and the dean.

My father said,”If he give you any trouble, bust his ass.”

I did not know this man from adam, but I knew that he was the father of one of the kids there and that he would be somewhere on campus when I got to high school. And now, he had free license to rough me up if I stepped out of line. But, any interaction I had with Forbes in the future, would be paired with this single recollection of his license to cut my ass

I am pretty well behaved, so not too worried about that, but I have a smart mouth and get bored easily. so I asked my brother.

He says (and I am paraphrasing), ” Yeah that is *some girl in his class* daddy. Mr. Forbes”

So. I avoided trouble (mostly) throughout 7th grade, except for Mr. Bennet (another post). But, during that time, we all heard about “Black Beauty”. The rumors said it was a metal antenna from a car, or a whale bone, or a wooden dowel, but it was wrapped in black electric tape. Interesting name, I guess and I imagine he thought it particularly witty.

In 8th grade, we had a new teacher for Spanish, Mr. Maximo Alcantara. Funny how I can remember his full name huh?

It was his first semester and in our class was one person who was in French the year before, Devin. Devin and I were cool.

He tried to explain to Mr. Alcantara that he was having trouble keeping up and had none of the books because he was in french the previous year. I cannot remember the words exactly, but I remember Mr. Alcantara being dismissive.
I thought he was wrong and being unreasonable. I said so. Smart mouth and all.

Long story short, he stopped class and walked Devin and I up to Mr. Forbes’ office. So about 27-28 students sitting in class without a teacher, while the teacher takes two students to get disciplined.

In Forbes’ office, Mr. Alcantara got the chance to explain what he saw as us being disrespectful and rude.

Again, I tried to explain that I was only trying to help. I was unsure, Mr. Alcantara understood what was going on and it was not Devin’s fault that the school could not accommodate his schedule and so he was shifted into spanish.

In the end, my first caning in high school was shared with Devin Adams, delivered by Mr. Forbes while Mr. Maximo Alcantara watched with smug satisfaction. I realize I am imagining this because when Forbes beat you you would face his desk and hold the edge while he pulled your pants taught. The door was behind you. and Mr. Alcantara was standing there hands crossed before I assumed the position.

afterward, Devin and I were sent to sit on a planter outside before returning to our scheduled classes. I still remember that sitting hurt, but standing was no different. I remember thinking there was no justice for us because we were weaker and had no power.

I remember never asking a question in Mr. Alcantara’s class again, by choice. Devin never said anything about the event either. Noone in class spoke about it, but when we had our freestyle rap sessions “Mad Max” became a featured topic.

SO in this case:
1: My father gave license for physical punishment to an unknown person in my presence. My perception was loss of autonomy and freedom, fear of this person and lack of justice.

2: Mr. Alcantara removed benefit from the class by stopping it, meaning the whole class was not learning. I like learning so I perceived this as my fault.

3: Alcantara distanced himself from the physical nature of the act by delivering us to another agent (Mr. Forbes), who in turn gave identity to his instrument in the name “Black Beauty”, which may also distance him from the act in some psychological way.

4: There was no assignment of the level of punishment to fit the crime, should I have gotten more or fewer for standing with Devin?

5: indeed I was unsure if Devin was caned for not having the book, for speaking up, or for pointing out the school’s failure to properly schedule him into the necessary classes (wait, that was the school’s fault).

6:the purpose was so that we would not question the authority, who in this case was wrong. There was no improvement of learning or deterrence of a negative behavior.

There will be more in this series, but for now, reply to this post and tell me how you feel about the event here, corporal punishment in general, its efficacy and implementation.


More information on corporal punishment and efforts to end it can be found here:
To Spank or Not to Spank?


GEE and R for Bahamian (and Caribbean) Birds

Essential to my understanding of science is that everything happens somewhere. and things that do not happen also “don’t happen somewhere”.

What that means is that knowing where a bird (or whatever your organism is) is may be as important as knowing where it does not occur. especially for conservation purposes. To get to this answer though, we need to know what we have seen, what areas or habitats we have visited and thereby, what areas we have not visited.

This is part of the reason I included “Geospatial” in Bahamians Educated in Natural and Geospatial Sciences in 2011, and why I am focusing heavily on the relationships between the data and locations in eBird for my dissertation.

I used open source coding programs (Google Earth Engine code API and R) with open access data (Landsat 8 and eBird), to create habitat maps and then align them with the biodiversity data for analysis. This means I had to learn to write code in the R programming language and Javascript for Google Earth Engine , and yes it was difficult. But, this means that with a very low power computer, I can now do amazing things and show people what is going on in the Bahamas and Caribbean, teach other young scientists to make reports without necessarily needing lots of funding or resources. I can share this expertise with organizations like the Bahamas National Trust or Department of Forestry rapidly to support conservation and protection efforts.

Equally important is the cost. Beyond internet access and a simple computer there is no need to pay for licenses when using open source and open access products. For products like ArcGIS or ENVI a year of work could easily cost you thousands of dollars.

If you would like to see some of the work I have done, visit my GitHUB page which includes all the R code for this part of the project. Yes, you can do it too! This means, that not only can I make useful data, but I can send it to someone else, who can then change some numbers or files and get the same output for a different year, a different location, a different species, etc. Those same people can also review, comment on, and help me to improve my code and output.

And this is at the core of my teaching and research philosophy. We should all be able to do good work quickly and efficiently, rapidly share with the stakeholders that need it and make it possible for local people and researchers to have input. So, go for it. check out the code on my github page and tell me how you would change or improve it.

Check out the images below and tell me what you think.

I made a habitat map and extracted the habitat at all the eBird locations on the island. and reported on how many locations had Detroit Audubon Society species of conservation concern and which had 16 species of Bahamian interest.

I decided to share this data with you because of the big difference in how much area is in each habitat on Grand Bahama and how many surveys are conducted in those areas.

In particular, sand if way over represented. That is because lots of observers are tourists on a beach or at a property near the beach. I consider them tourists because their visits are seasonal or one time only and they occur near tourist properties or developments.

NB: I trimmed Grand Bahama to the contiguous area you can get to without getting wet. I tried my best to make the images colorblind friendly the habitat map was not possible.

Grand Bahama Island Contiguous area habitat map with legend and axes.jpeg
Grand Bahama habitat map 2017, generated in R and Google Earth Engine


Square Km per habitat on Grand Bahama 2017


habitat type in ebird surveys colorblind

>>>>Here is a snippet of code for those that will not follow the links.

##display the clipped raster####
GBcontiguoushab.range<-cellStats(GBcontiguoushab, range)

plot(GBcontiguoushab,#plot this raster file
col=col7class, #a list of colors make sure they are in the order of the classes you are plotting
at= #how do you want the axis labels spread out?
seq(#sequential separations from the
GBcontiguoushab.range[1],#lowest end of the range
GBcontiguoushab.range[2], #to the highest end of the range
1),#with one unit of separation between each tick mark
labels=legend, #at each tick mark, what do you want the label to say?
axes=T ,
main = “Grand Bahama Island, Bahamas habitat map”, #title of the plot
ylab=”Latitude”, #left side
xlab=”Longitude”, #x axis label
las=1 #rotate the y axis labels to horizontal
plot(GBOutlineWGS84, add=T)
legend(‘bottomright’, legend , fill=col7class, border=”black”,
col=col7class, bty=’n’, cex=1.5)
#summarize the number of pixels and the geographic area in each class####
habitatpixels<-count(GBhabitatdf, “RFclass6bands30m7classes2017”)
habitatareakm2<- #a vector of the total area in each habitat type
(habitatpixels$freq[1:7] #1:7 selects the columns with the classes 0-6 and ignores the NA values
)*0.0009 #0.0009 is the number of km2 in a 30 x 30 m pixel (Landsat 8 imagery)
totalpixels<- #vector for the total pixels in the study area
totalarea<-#vector of total area in study area
percentarea<-habitatareakm2/totalarea #%of total area in each habitat type


Leno’s new joke June 5 2018

The chicken saw the perfect kernel of corn. It was so perfect, she could not eat it.

It was impeckable.

Sent from my iPad

Bird occurrence in the Bahamas

If you have not yet seen Tony White’s Birder’s Guide to the Bahamas, one of the most valuable things I find that he did was his presence absence chart. You can use his chart to find out which Bahamian islands you should visit to see the birds you are interested in. In my dissertation, I generate similar tables using eBird data and Tableau or R.

Here is a sample of species I chose because the Detroit Audubon Society listed them as potential species in collaborative education work in the Bahamas and Michigan; they are breeding residents on Grand Bahama (per Lloyd and Slater 2011) or common species that don’t get enough respect.

I know there are some conspicuous absences, but my dissertation focuses on Grand Bahama Island, so no Abaco Parrots, Bahama Oriole or Pearly Eyed Thrashers. However, the code that I am creating is adaptable so once it is published ANYONE can download and run it and change a few words or lines to get all the species you want.

Which species would you add to the list or how would you like me to adjust the display?

Beauty. Grown up.

I remember the first time I thought about asking Alma to marry me. I was looking at her laughing while talking to her mom, sister and brother on the phone. She did it every day and still does almost every day. I recognized at that time, her closeness with her family was something I wanted to be a part of and if there came a point when I had to choose between that laugh and any other sound, I would choose her every time.

I remember catching the bus to the mall to choose an engagement ring to replace the promise ring I had given her. Asking her to see the rings she wore to try to remember how they fit on my pinky finger. Saving up, because an engagement ring should be worth at least a month’s salary … trying to hide the question behind my eyes every time I looked at her.

I remember marrying her. The biggest day of my life at that time. I remember imagining forever with the same wonderful, amazing, beautiful woman. I remember.

And since then, every day is a new memory. But now, I realize, forever is with a new woman in Alma every day. I am still learning more about her. The way she thinks, what she believes, why she worries, how she loves me and our boys.

Today, the woman I fell in love with is one year older. Again she is more beautiful than every year before.

Happy Birthday Guapa!

Te Quiero Mucho.

Mixing your seed interferes with the diversity of nature! (My response)

A Facebook friend recently posted:

Mixing your seed interferes with the diversity of nature!

Ok. Basic rejection of the sentiments in this post.

Starting with the definitions.

Mixing of seed. I and most of the respondents on the original post take this to mean reproducing with others outside of your race. This is evident in the responses and Anku Sa Ra’s responses to them.

Interferes. This implies that the mixing of seed is contrary to the natural order of diversity in nature.

The diversity literally means variety. Numbers of different things in the simplest sense.

Nature. Occurring outside of deliberate intervention or man made influence.

If you are against the rest of what I am writing, start by telling me where these definitions are wrong.

Now. First, mixing of seed implies that there are fundamental differences between the seed (genetic material) of the races. And within the framework of the statement, differences that do not occur in nature. It is not true. Lots of racist scientists have tried to establish boundaries between (artificially constructed) races, eugenics is the most well known. But, we are all one species. We can all interbreed. Though there is lots of variation which is reduced within close proximity within geographically isolated populations, but that does not stop reproduction even between individuals whose ancestors have not crossed paths in millennia .

Diversity in nature indeed hinges upon differences between people and organisms. Sickle cell and other variations in our genes allow various groups to survive mosquito borne diseases as an example. Without variation, one catastrophe could wipe out an entire population by climate change disease etc. so micro and macro evolution work to counter these possibilities and the diversity in nature becomes greater over time unless interrupted by outside forces.

Interfering with natural diversity cannot happen by “mixing seed” in fact, that would contribute to the diversity in nature as it has since the beginning of earth biology. when humans have reduced the mixing of seed, it has inherently created weaker populations. Monocultures like corn and Augustina grasses for example take huge investments to maintain their health as they become less and less genetically diverse, especially under shifting climatic conditions. Isolated populations such as native people of the americas were hit hard with introduced diseases from the old world. Many such people died out due to the combination of deliberate genocide, enslavement and disease.

Granted, I am phenotypically black by American standards and married to a Mexican woman with whom I have two amazing sons, so I do have an emotional horse in this race. Heh. Race. And full disclosure, all of my brothers have children across cultures and what some would call races.

At the core, a statement like this, by a religious leader disgusts me. But, once I put that aside, it is wholly an unsupported opinion.

Some references:

the diversity of life by E.O. Wilson;

The Naked Ape by Desmond Morris;

Evolution at Berkeley

Indiana discusses convolution and the red queen hypothesis here.

This nature article highlights genetic drift and loss of diversity in populations.

This article points out how race and ethnicity arguments blur the understanding of genomics.

Inside and inside dog

Inside every inside dog is an outside dog waiting to get out. Inside every outside dog is an inside dog waiting to get in.

Sent from my iPad

A Website.

Up ↑