Skip to content

Instantly share code, notes, and snippets.

View mgaynor1's full-sized avatar

Shelly Gaynor mgaynor1

View GitHub Profile
@mgaynor1
mgaynor1 / process_data_chrom
Created December 2, 2024 19:08
AlternativeFunction-nQuack
process_data_chrom <- function(file, min.depth = 2, max.depth.quantile.prob = 0.9,
error = 0.01, trunc = c(0,0), chrom){
df <- data.table::fread(file, sep = "\t")
if(ncol(df) != 7){
message("Did you run `prepare_data()` on this file? Your data is in the wrong format, please correct and try again.")
} else{
df <- df[which(df$chr == chrom), 3:7]
df <- stats::na.omit(df)
dfm <- as.matrix(df)
# R example
# Load packages
library(rgbif)
# Download Option #1 - based on scientificName
gbif_data <- occ_data(scientificName = "Cryptantha pterocarya var. purpusii")
## Now look at verbatim record
gbif_data$data$key <- as.numeric(gbif_data$data$key)
query_gbif <- rgbif::occ_get_verbatim(key = gbif_data$data$key, fields = c("scientificName"), curlopts=list(http_version=2))
collector_clean <- function(df, collector.list = NA, collector.field = "recordedBy"){
if (NROW(df) == 0) return(df)
if(any(is.na(collector.list)) | length(collector.list) == 0){
record.filter <- "interactive"
} else{
record.filter <- "list-based"
}
if (record.filter == "interactive" ) {
# Load packages
library(ridigbio)
library(gatoRs)
# Download for Galax
sout <- idig_search(rq =list(scientificname = "Galax urceolata")) # exact match
rout <- idig_search(rq = list("data" = list("type" = "fulltext","value" = "Galax urceolata"))) # searches all data fields strings for a partial match
bestout <- gatoRs::gators_download(synonyms.list = "Galax urceolata") # searches like above, then applies pseduo-fuzzy match
# Look at the taxa
a<- read.csv2("SupplementalInformation_FinalOccurrenceRecords.csv",sep=',')
b <- list()
for(1:length(a)){
b[i] <- gbif_citation(a$key[i])$citation$text
}
try <- idig_search_records(rq = list("data.dwc:dynamicProperties" = list("Mrs", "Ms", "Miss")))
# Might be better to try
idig_search_records(rq=list('data'=list('type'='fulltext','value'='alligator')))