import {readStudyAccession} from "./study-link.js"
study_accession = readStudyAccession(window.location.search)
html`<form method="get" class="study-controls">
<label>Study accession
<input name="study" value=${study_accession} pattern="MGYS[0-9]{8}" required>
</label>
<button type="submit">Open study</button>
</form>`MGnify API in R
Find a study, explore its analyses, and read a result table.
Edit and run the cells below, in order. The first visit may take a minute to load. Copy any code you want to keep before leaving or reloading the page.
Set up
The study accession comes from the box above.
Get a study
A study groups related samples and analyses. Retrieve its title and biome:
List its analyses
List responses contain items and a total count. Fetch the first 20 analyses; change page=1 to page=2 to get the next page.
Inspect an analysis
Choose the first analysis, or replace ANALYSIS with another accession from the list. Its detail record includes the available result files.
Read a result table
For this analysis, load the Pfam domain-count summary into a data frame. Other analyses may have different files; use the descriptions above to choose a result.
The download is a gzip-compressed TSV; R reads it directly with read.delim(). Choose small summaries when working in your browser.
Explore the counts
Show the ten most frequent Pfam domains. Try changing 10 to 20.
Running this code in your own environment
Install jsonlite from your R console:
install.packages("jsonlite")Copy the R cells into RStudio or an R script, replacing STUDY <- study_accession with STUDY <- "MGYS00010393" (or your chosen accession).