# Get all MPD's phenotype data for a certain strain panel (BXD)
library(jsonlite)
library(RCurl)
library(data.table)
# find all MPD projects that involve BXD phenotype data...
url <- paste("https://phenome.jax.org/api/projects?panelsym=BXD&mpdsector=pheno")
allbxd_projects_json <- getURL(url)
allbxd_projects_data <- fromJSON(allbxd_projects_json)
# iterate across the above projects and use projsym...
for(i in 1:dim(allbxd_projects_data$projects)[1]) {
prjsym = allbxd_projects_data$projects$projsym[i]
# get measure descriptions and metadata for the project...
url = paste("https://phenome.jax.org/api/pheno/measureinfo/",prjsym,sep="")
prj_desc_json = getURL(url)
prj_desc_data = fromJSON(prj_desc_json)
print(prj_desc_data$measures_info)
# get all strain/sex averages for the project...
url = paste("https://phenome.jax.org/api/pheno/strainmeans/",prjsym,sep="")
strain_means_json = getURL(url)
strain_means_data = fromJSON(strain_means_json)
# get individual animal data for every measure in the project...
for(j in 1:dim(prj_desc_data$measures_info)[1]){
measure_id = prj_desc_data$measures_info$measnum[j]
url = paste("https://phenome.jax.org/api/pheno/animalvals/",measure_id,sep="")
individual_animal_json = getURL(url)
individual_animal_data = fromJSON(individual_animal_json)
}
}