Medical-research-skills singlecell-portal
Programmatically query public single-cell study metadata from the Broad Institute Single Cell Portal REST API when you need to search and filter datasets by organism, tissue, disease, or cell type without an API key.
install
source · Clone the upstream repo
git clone https://github.com/aipoch/medical-research-skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/aipoch/medical-research-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/scientific-skills/Data Analysis/singlecell-portal" ~/.claude/skills/aipoch-medical-research-skills-singlecell-portal && rm -rf "$T"
manifest:
scientific-skills/Data Analysis/singlecell-portal/SKILL.mdsource content
When to Use
- You need to discover relevant public single-cell studies by filtering on organism (e.g., human/mouse) and tissue (e.g., lung/brain).
- You want to quickly retrieve study-level metadata (e.g., study name, accession, cell counts) for downstream curation or reporting.
- You are building a script or tool that needs no authentication and should work reliably on Windows with minimal setup.
- You want to inspect available filter facets (what tissues/diseases/cell types exist in the index) before constructing queries.
- You need a lightweight way to validate that a study exists and fetch its details by accession.
Key Features
- Direct REST access to the official Single Cell Portal API (
)/single_cell/api/v1/* - No API key required (public endpoints)
- Faceted search for studies (organism, tissue, disease, cell type, etc.)
- Retrieve facet dictionaries to build valid filters
- Retrieve study details by accession
- Minimal dependency footprint (only
)requests - Windows-friendly behavior (optional SSL verification disablement for certificate issues)
Dependencies
requests==2.31.0
Example Usage
import requests BASE_URL = "https://singlecell.broadinstitute.org/single_cell/api/v1" def scp_get(path: str, params=None, verify_ssl: bool = True, timeout: int = 30): """ Minimal helper for Single Cell Portal API calls. Security note: - Only call official endpoints under: https://singlecell.broadinstitute.org/single_cell/api/v1/* - If you encounter Windows certificate issues, set verify_ssl=False. """ url = f"{BASE_URL}{path}" resp = requests.get(url, params=params or {}, timeout=timeout, verify=verify_ssl) resp.raise_for_status() return resp.json() def search_studies(facets: str, size: int = 5): return scp_get("/search", params={"facets": facets, "size": size}) def get_facets(): return scp_get("/search/facets") def get_study(accession: str): return scp_get(f"/studies/{accession}") if __name__ == "__main__": # 1) Search: human lung studies results = search_studies("organism:human,tissue:lung", size=5) studies = results.get("studies", []) print("Top matches:") for s in studies: print(f"- {s.get('name')} | accession={s.get('accession')} | cells={s.get('cell_count')}") # 2) Inspect available facet values (useful to build valid filters) facet_info = get_facets() print("\nFacet keys available:", ", ".join(sorted(facet_info.keys()))) # 3) Fetch details for the first returned study (if any) if studies and studies[0].get("accession"): acc = studies[0]["accession"] detail = get_study(acc) print(f"\nStudy detail for {acc}:") print("Name:", detail.get("name")) print("Description:", detail.get("description"))
Implementation Details
- Base endpoint constraint: All network requests must target
https://singlecell.broadinstitute.org/single_cell/api/v1/*
(no third-party URLs). - Core endpoints:
: returns study search results (metadata)GET /search
: returns available facet keys/values for filteringGET /search/facets
: returns details for a specific studyGET /studies/{accession}
- Facet filtering (
parameter):facets- Format: comma-separated
pairs, e.g.key:valueorganism:human,tissue:lung - Common facet keys include:
,organism
,tissue
,diseasecell_type - Some values may be multi-word (e.g.,
); pass them as-is in the string.T cell
- Format: comma-separated
- Pagination / result size:
controls the number of returned studies (default behavior depends on the API; set explicitly for deterministic results).size
- SSL handling on Windows:
- If certificate verification fails in certain environments, you may set
inverify=False
.requests.get(...) - Prefer
when possible; disabling verification reduces transport security.verify=True
- If certificate verification fails in certain environments, you may set
- Error handling:
- Use
to surface HTTP errors.response.raise_for_status() - Treat missing keys defensively (
) because response shapes may evolve.dict.get
- Use
- Data scope:
- The API primarily returns metadata; raw data downloads typically occur via the portal’s dataset pages and are not covered by these endpoints.