Access the VecTraits API

You can access the API calls here.

We have also generated a number of example . R scripts you can use to access the API from within the .R environment. Download the scripts here and documentation is here below:

Retrieve a Dataset by Its ID

Format: dataframe <- getDataset(<Dataset ID>)

Examples:

list <- getDataset(50) # Get dataset with ID 50

list <- getDataset(“120”) # Get dataset with ID 120

list <- getDataset(552L) # Get dataset with ID 552

list <- getDataset(579) # Get dataset with ID 579

Retrieve Multiple Datasets by Their IDs

Format: list_of_dataframes <- getDatasets(<Vector, List, or Range of IDs>)

Examples:

list_of_dataframes <- getDatasets(c(10, 20, 35)) # Get datasets 10, 20, and 35

list_of_dataframes <- getDatasets(seq(200, 240, 10)) # Get datasets 200, 210, 220, 230, and 240

list_of_dataframes <- getDatasets(list(50, 1, 580, 20)) # Get datasets 1, 20, 50, and 580

list_of_dataframes <- getDatasets(320:324) # Get datasets 320, 321, 322, 323, and 324


Retrieve List of Datasets Related To Keyword

Format:

list_of_dataframes <- searchDatasets(<Keyword>)

Examples:

list_of_dataframes <- searchDatasets(“tiger mosquito”) # Get datasets related to tiger mosquitos

list_of_dataframes <- searchDatasets(“TIGER MOSQUITO”) # Get datasets related to tiger mosquitos

list_of_dataframes <- searchDatasets(“TiGEr mOSquitO”) # Get datasets related to tiger mosquitos

list_of_dataframes <- searchDatasets(“aphid”) $ Get datasets related to aphids

Retrieve List of Datasets Related To Multiple Keywords


Format:

list_of_dataframes <- searchDatasetsMulti(<Vector or List of Keywords>)


Examples:

(All the following retrieve datasets related to yellow fever & terrestrial areas in North Carolina)

list_of_dataframes <- searchDatasetsMulti(c("terrestrial", "north carolina", "yellow fever"))

list_of_dataframes <- searchDatasetsMulti(list("terrestrial", "north carolina", "yellow fever"))

list_of_dataframes <- searchDatasetsMulti(c("TERRESTRIAL", "NORTH CAROLINA", "YELLOW FEVER"))

list_of_dataframes <- searchDatasetsMulti(list("tERRestRiAL", "NoRTh CARoLina", "YELLow feVer"))


Retrieve List of Datasets By Column Values

Format:

list_of_dataframes <- smartSearch(<Column Name>, <Column Value>, <Optional Operator>)

Examples:

list_of_dataframes <- smartSearch(“Interactor1Genus”, “culex”) # Datasets with genus Culex

list_of_dataframes <- smartSearch(“SubmittedBy”, “Lachance”) # Datasets submitted by Lachance

list_of_dataframes <- smartSearch(“Interactor2Species”, “null”, “neq”) # Datasets with second interactor

list_of_dataframes <- smartSearch(“OriginalTraitName”, “survival”, “eq”) # Datasets strictly about survival

The  pick() Function

If all the information above was too much and there’s no way you’re going to remember it, all you need to know is the “pick()” function.  The “pick()” function displays a small menu and allows you to choose an option in order for you to find and retrieve whatever dataset(s) you may be looking for.


Format:

x <- pick()


Example: (Including Human Input and  Computer Response)

x <- pick()

MENU:

 [1] Retrieve dataset by ID

 [2] Retrieve datasets by IDs

 [3] Search for datasets by keyword

 [4] Search for datasets by list of keywords

 [5] Search for datasets by variable and value

Enter a number from the menu above to select it. 4

Please enter a list of keywords to search for in the datasets:

1: Mosquito

2: Survival

3: Yellow fever

5: North Carolina

7: 

Read 6 items

Searching Datasets....

3 relevant datasets found.

This will take about 4 seconds.

Retrieving datasets....

=== 100%

Data retrieval complete!

Access Dataframes In Lists

When multiple datasets are retrieved and stored in a list of dataframes, you can access individual datasets with the following format:

first_dataframe <- list_of_dataframes[[1]]

second_dataframe <- list_of_dataframes[[2]]

third_dataframe <- list_of_dataframes[[3]]

...and so on for every dataframe in the list.

Example:

To print a list of the names of those who contributed to the datasets related to tiger mosquitos:

list_of_dataframes <- searchDatasets(“tiger mosquito”)

for (i in 1:length(list_of_dataframes)) {

  print(list_of_dataframes[[i]]$results$SubmittedBy[1])

}

Access Data In Dataframes

To access variable x in row y of a dataset stored as a dataframe, use the $ symbol and square brackets []:

variable_value <- dataframe$results$x[y]

For example, if you had a dataset stored as a dataframe and you wanted to know the Genus of Interactor 1 in the fifth row, you could get that with the following code:

dataframe$results$Interactor1Genus[5]

The same format also works for dataframes in lists.  For example, you could run the following to get the original trait value in row 3 of the fourth dataset in the list:

list_of_dataframes[[4]]$results$OriginalTraitValue[3]

The same format also works on raw functions, although it is recommended that retrieved datasets are immediately stored in an R object:

getDataset(5)$results$SubmittedBy[1] # Name of person who submitted the dataset with ID 5

Minor Additional Functions

datasetSummary(DATASET)

Summary: Prints summary of data within dataset

Parameters: DATASET = A dataset as a dataframe, such as getDataset(1)

Returns: Nothing


sciName(DATASET)

Summary: Finds the scientific name of the main interactor within the dataset

Parameters: DATASET = A dataset as a dataframe, such as getDataset(1)

Returns: Scientific Name of main interactor within dataset, as string

datasetRows(DATASET)

Summary: Finds the number of rows/samples in a dataset

Parameters: DATASET = A dataset as a dataframe, such as getDataset(1)

Returns: Number of rows, as integer

datasetColumns(DATASET)

Summary: Finds the number of columns/variables in a dataset

Parameters: DATASET = A dataset as a dataframe, such as getDataset(1)

Returns:Number of columns, as integer

Previous
Previous

Understanding VecDyn error flags for re-digitized data

Next
Next

Apply Now for the VectorByte training workshop (July 2023)