In the second post of the series where we obtained data from
eBird we
determined what birds were observed in the county of Constance, and we
complemented this knowledge with some taxonomic and trait information in
the fourth post of the
series. Now,
we could be curious about the occurrence of these birds in scientific
work. In this post, we will query the scientific literature and an open
scientific data repository for species names: what have these birds been
studied for? Read on if you want to learn how to use R packages allowing
to do so!
Getting a list of 50 species from occurrence data
For more details about the following code, refer to the previous post
of the series.
The single difference is our adding a step to keep only data for the
most recent years.
# polygon for filtering
landkreis_konstanz %
fulltext::ft_collect() %__%
fulltext::ft_chunks(c(&quot;title&quot;, &quot;abstract&quot;)) %__%
fulltext::ft_tabularize() %__%
dplyr::bind_rows()
}
.get_papers(species[1]) %__%
dplyr::pull(title)
## [1] &quot;Great spotted cuckoo nestlings have no antipredatory effect on magpie or carrion crow host nests in southern Spain&quot; ## [2] &quot;Donor-Control of Scavenging Food Webs at the Land-Ocean Interface&quot; ## [3] &quot;Formal comment to Soler et al.: Great spotted cuckoo nestlings have no antipredatory effect on magpie or carrion crow host nests in southern Spain&quot;
## [4] &quot;Socially Driven Consistent Behavioural Differences during Development in Common Ravens and Carrion Crows&quot; ## [5] &quot;Behavioral Responses to Inequity in Reward Distribution and Working Effort in Crows and Ravens&quot; ## [6] &quot;Early Duplication of a Single MHC IIB Locus Prior to the Passerine Radiations&quot; ## [7] &quot;Investigating the impact of media on demand for wildlife: A case study of Harry Potter and the UK trade in owls&quot; ## [8] &quot;New Caledonian Crows Rapidly Solve a Collaborative Problem without Cooperative Cognition&quot; ## [9] &quot;Nest Predation Deviates from Nest Predator Abundance in an Ecologically Trapped Bird&quot; ## [10] &quot;Dietary Compositions and Their Seasonal Shifts in Japanese Resident Birds, Estimated from the Analysis of Volunteer Monitoring Data&quot;
If we were working on a scientific study, we’d add a few more filters,
e.g. having the species mentioned in the abstract, and not only
somewhere in the paper which is probably the way the different
literature search providers define a match. But we’re not, so we can
keep our query quite free! My favourite paper involving the Carrion Crow
is “Investigating the impact of media on demand for wildlife: A case
study of Harry Potter and the UK trade in
owls”
because it’s a fun and important scientific question, and is supported
by open data (by the way you can access CITES trade data (international
trade in endangered species) in R using
cites and CITES
Speciesplus database using
rcites).
We then apply this function to all 50 species and keep each article only
once.
get_papers %
unnest_tokens(word, text) %__%
dplyr::filter(!word %in% stopwords) %__%
dplyr::count(word, sort = TRUE) -__ words
So, what are the most common words in these papers?
head(words, n = 10) ## word n
## 1 species 754
## 2 birds 514
## 3 virus 270
## 4 avian 268
## 5 bird 262
## 6 study 243
## 7 breeding 231
## 8 wild 227
## 9 populations 217
## 10 population 213
Not too surprising, and obviously less entertaining than looking at
individual species’ results. Maybe a wordcloud can give us a better idea
of the wide area of topics of studies involving our 50 most frequent
bird species. We use the wordcloud
package.
library(&quot;wordcloud&quot;)
with(words, wordcloud(word, n, max.words = 100))
We see that topics include ecological words such as “foraging” but also
epidemiological questions since “influenza” and “h5n1” come up. Now, how
informative as this wordcloud can be, it’s a bit ugly, so we’ll prettify
it using the wordcloud2
package instead, and the
silhouette of a bird from
Phylopic.
bird %
head(n = 100) %__%
wordcloud2::wordcloud2(figPath = &quot;bird.png&quot;, color = &quot;black&quot;, size = 1.5)
# https://www.r-graph-gallery.com/196-the-wordcloud2-library/
htmlwidgets::saveWidget(bird,
&quot;tmp.html&quot;,
selfcontained = F)
I wasn’t able to webshot the resulting html despite increasing the
delay parameter so I screenshot it by hand!
magick::image_read(&quot;screenshot.png&quot;)
wordcloud shaped as a bird
The result is a bit kitsch, doesn’t include the word “species”, one
needs to know it’s the silhouette of a bird to recognize it, and we’d
need to work a bit on not reshaping the silhouette, but it’s fun as it
is.
Querying scientific open data
There are quite a few scientific open data repositories out there, among
which the giant DataONE that has an API
interfaced with an R package. We shall use it to perform a search
similar to the previous section, but looking at the data indexed on
DataONE. Since DataONE specializes in ecological and environmental data,
we expect to find rather ecological data.
We first define a function to retrieve metadata of datasets for one
species. It looks the species names in the abstract.
.get_meta %
tolower() %__%
fulltext::ft_search() %__%
fulltext::ft_get() %__%
fulltext::ft_collect() %__%
fulltext::ft_chunks(c(&quot;title&quot;, &quot;abstract&quot;)) %__%
fulltext::ft_tabularize() %__%
dplyr::bind_rows()
fulltext gives you a lot of power! Other rOpenSci accessing literature
data include europepmc, R
Interface to Europe PMC RESTful Web Service;
jstor;
suppdata for extracting
supplemental information, and much
more.
Scientific data access… and publication with R
In this post we used the dataone
package to access data from
DataONE. That same package allows uploading data to DataONE. The
rOpenSci suite features the
rfigshare package for getting
data from, and publishing data to, Figshare.
For preparing your own data and its documentation for publication, check
out the EML package for writing
metadata respecting the Ecological Metadata Standard, and the unconf
dataspice project for
simpler metadata entry.
Explore more of our packages suite, including and beyond access to
scientific literature &amp;data and data publication,
here.
No more birding? No, your turn!
This was the last post of this series, that hopefully provided an
overview of how rOpenSci packages can help you learn more about birds,
and can support your workflow. As a reminder, in this series we saw
How to identify spots for birding using open geographical
data.
Featuring opencage for geocoding, bbox for bounding box
creation, osmdata for OpenStreetMap’s Overpass API querying,
osmplotr for map drawing using OpenStreetMap’s data.
How to obtain bird occurrence data in
R.
Featuring rebird for interaction with the eBird’s API, and auk
for munging of the whole eBird dataset.
How to extract text from old natural history
drawings.
Featuring magick for image manipulation, tesseract for Optical
Character Recognition, cld2 and cld3 for language detection, and
taxize::gnr_resolve for taxonomic name resolution.
How to complement an occurrence dataset with taxonomy and trait
information.
Featuring taxize, taxonomic toolbelt for R, and traits,
providing access to species traits data.
How to query the scientific literature and scientific open data
repositories. This is the post you’ve just read!
That’s a wrap! But now, don’t you hesitate to explore our packages
suite for your own needs, and to share about your use cases of rOpenSci
packages as a birder or not via our friendly discussion
forum! Happy birding!