You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One function that I've been missing is to upgrade/downgrade taxonomy to a certain level.
I have observations identified as either Otolemur garnettii or Otolemur when I could not be sure of the species. For the analysis, I would like to lump all Otolemur garnettii to the higher taxonomic level Otolemur while maintaining x$taxonomy correct. As I understand the structure, I would have to modify observation$scientificName as well as all observation$taxon.xxxx columns. Then, using update_taxonomic() it would take care of removing Otolemur garnettii, right? Would that work?
Next, a bit more complex, I have observations identified as either Paraxerus ochraceus or Paraxerus palliatus. How to lump all of these observations to the higher taxonomic level Paraxerus sp while this does not currently exists in x$taxonomy.
Here is my current solution. Maybe there is a way to generalized an make it as a function to the package? Not sure if this would be helpful.
# Define taxonomy changetaxon_change=list(
list(
from="Otolemur garnettii", # Garnett's Greater Galagoto="Galago"# Galago sp
),
list(
from="Paraxerus ochraceus", # Ochre Bush Squirrelto="Paraxerus"# Paraxerus sp.
),
list(
from="Paraxerus palliatus", # Red Bush Squirrelto="Paraxerus"# Paraxerus sp.
)
) %>% bind_rows()
# Needs to be performed before changing observationstaxonomy<-camtrapdp:::taxonomic(x)
# Update the observations table. Note that I have not added the `taxon.xxxxx` at this stage to make the change of taxa more easilycamtrapdp::observations(x) <-camtrapdp::observations(x) %>%
left_join(taxon_change, by= c("scientificName"="from")) %>%
mutate(scientificName= coalesce(to, scientificName)) %>%
select(-to)
# Read all taxonomy (rely on an external taxonomy with all informations) wi_taxonomy<- read_csv("data/wi_taxo_mammals.csv", show_col_types=FALSE, guess_max=8000) %>%
# match to taxonomy structure
transmute(
taxonID=.data$uniqueIdentifier,
taxonIDReference="https://github.com/ConservationInternational/Wildlife-Insights----Data-Migration/tree/master/WI_Global_Taxonomy",
scientificName=dplyr::case_when(
!is.na(.data$species) &!is.na(.data$genus)
~ paste(.data$genus, .data$species),
!is.na(.data$genus) ~.data$genus,
!is.na(.data$family) ~.data$family,
!is.na(.data$order) ~.data$order,
TRUE~class
),
taxonRank=dplyr::case_when(
!is.na(.data$species) &!is.na(.data$genus) ~"species",
!is.na(.data$genus) ~"genus",
!is.na(.data$family) ~"family",
!is.na(.data$order) ~"order",
TRUE~"class"
),
kingdom="Animalia",
# phylum = not present, likely Chordataclass=class,
order=order,
family=family,
genus=genus,
vernacularNames.en=commonNameEnglish
)
# Update taxony with the changetaxonomy<-taxonomy %>%
filter(!(scientificName%in%taxon_change$from)) %>%
bind_rows(
wi_taxonomy %>% filter(scientificName%in%taxon_change$to)
) %>%
unique()
# Add taxonomic info to observations: Same as camtrapdp::read_camtrapdp()if (!is.null(taxonomy)) {
# Add taxon. as column suffix
colnames(taxonomy) <- paste("taxon", colnames(taxonomy), sep=".")
# Join taxonomy with observationscamtrapdp::observations(x) <-camtrapdp::observations(x) %>%
dplyr::left_join(
taxonomy,
by=dplyr::join_by("scientificName"=="taxon.scientificName")
)
}
The text was updated successfully, but these errors were encountered:
One function that I've been missing is to upgrade/downgrade taxonomy to a certain level.
I have observations identified as either Otolemur garnettii or Otolemur when I could not be sure of the species. For the analysis, I would like to lump all Otolemur garnettii to the higher taxonomic level Otolemur while maintaining
x$taxonomy
correct. As I understand the structure, I would have to modifyobservation$scientificName
as well as allobservation$taxon.xxxx
columns. Then, usingupdate_taxonomic()
it would take care of removing Otolemur garnettii, right? Would that work?Next, a bit more complex, I have observations identified as either Paraxerus ochraceus or Paraxerus palliatus. How to lump all of these observations to the higher taxonomic level Paraxerus sp while this does not currently exists in
x$taxonomy
.Here is my current solution. Maybe there is a way to generalized an make it as a function to the package? Not sure if this would be helpful.
The text was updated successfully, but these errors were encountered: