Tutorial - Using the MPD data API
Tutorials intended for developers interested in programatically accessing data using MPD's data API.


Get all numeric phenotype data for a strain panel e.g. BXD ....

  • Discover available strain panel terms:   https://phenome.jax.org/api/project_filters/panelsym

  • Find all MPD phenotype projects associated with a strain panel term. Here we'll use BXD.
    Call this endpoint: https://phenome.jax.org/api/projects?panelsym=BXD&mpdsector=pheno
    The result JSON payload will have attributes for each project.

  • Iterate over the projects element in the above JSON payload and use the projsym (project identifier) element. Suppose the above payload includes these projsyms: Crusio1, Donahue14, Spijker1 ...

  • Python code example to do the above
            # run this in a python3 virtual environment
            import requests
    
            baseurl = "https://phenome.jax.org/api"
    
            # find all MPD projects that involve BXD phenotype data...
            url = baseurl + "/projects?panelsym=BXD&mpdsector=pheno"
            projects = requests.get( url ).json()["projects"]
    
            # iterate across the above projects and use projsym...
            for proj in projects:
                projsym = proj["projsym"]
    
                # get the project's measure descriptions and metadata...
                url = f"{baseurl}/pheno/measureinfo/{projsym}"
                prj_desc = requests.get( url ).json()["measures_info"]
    
                # get the project's strain/sex averages...
                url = f"{baseurl}/pheno/strainmeans/{projsym}"
                strain_means = requests.get( url ).json()["strainmeans"]
    
                # get the project's available individual animal numeric data...
                for measure in prj_desc:
                    measure_id = measure["measnum"]
                    if measure["granularity"] != "animal" or measure["datatype"] == "categorical":
                        continue
                    url = f"{baseurl}/pheno/animalvals/{measure_id}"
                    animal_data = requests.get( url ).json()["animaldata"]
    
    R code example to do the above
            # 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)
              }
            }
    



    Get all numeric phenotype data supplied by a center e.g. HMDP ....

  • Discover available terms for centers:   https://phenome.jax.org/api/project_filters/largecollab

  • Find all MPD phenotype projects from the desired center. In this example we'll use HMDP.
    Call this endpoint: https://phenome.jax.org/api/projects?largecollab=HMDP&mpdsector=pheno

  • The rest is exactly the same as described above for strain panels.
    Iterate over the projects element and go from there.



  • Get all publications associated with all projects in the QTL Archive ....

  • Find all MPD projects in the QTL Archive:
    Call this endpoint: https://phenome.jax.org/api/projects?mpdsector=qtla

  • Iterate over the projects element in the above JSON payload and use the projsym (project identifier) element.