From Python and R
Read your datasets, the analyses built on them and what they found, follow where a result came from, add new versions and track your runs, from your own code or an AI agent.
Get a key
Open Account, then API keys, and click New key. Choose
Read, or Read and add data when your code uploads. A key works as you: it opens what you can open on
the site and nothing more. It is shown once; set it as BASEQ_API_KEY where your code runs.
Install
pip install "baseqdb[pandas]" # Python 3.10 or later
# R 4.2 or later, with no Python needed
install.packages("baseqdb",
repos = c("https://baseq.bio/r", "https://cloud.r-project.org"))
A dataset
import baseqdb as bq
bq.login() # reads BASEQ_API_KEY
bq.Dataset.filter(kind="bulk").to_dataframe() # yours, newest versions
ds = bq.Dataset.get("kTIqMTTm89P2gbNU0000") # one version, by its uid
ds.versions # every version you see
folder = ds.cache() # its files, downloaded once
sheet = ds.sample_sheet # a DataFrame
In R the same names, with $:
library(baseqdb)
bq_login()
ds <- Dataset$get("kTIqMTTm89P2gbNU0000")
folder <- ds$cache()
sheet <- ds$sample_sheet # a data.frame
Analyses and what they found
bq.Analysis.filter(kind="bulk").to_dataframe() # every analysis you can open
analysis = ds.analyses[0] # or those of one dataset
analysis.steps.to_dataframe() # each step, its settings, when it ran
analysis.findings.to_dataframe() # what each step found
table = analysis.tables["dge_condition_dexamethasone_vs_untreated.csv"].load()
Where a result came from
record = bq.Record.get("Z3HMY4V1wC6goA380000") # a file a step wrote
record.run # its step, settings, environment
record.run.inputs # the records it read
Add a version
With a Read and add data key. A dataset you add goes through the same checks as an upload; with the name of one you have, it is its next version, and it starts what When a new version is added says.
new = bq.Dataset(["counts_filtered.tsv"], name="Airway demo (GSE52778, 4 samples)",
kind="bulk", sample_sheet="samples.csv").save()
new.version # 2: the next version
Track your code
One line at the top makes the script one run on baSeq: its code, the data it reads, what it adds and what it found. Reads are counted, not listed one by one; everything a run adds is kept.
bq.track() # this script, as one run
counts = ds.files["counts.tsv"].load() # noted as what the run read
bq.Record("dge_dex.csv").save() # a file of the run
bq.finish(finding="Dexamethasone raised ZBTB16, FKBP5, KLF15 and PER1 the most.",
genes=["ZBTB16+", "FKBP5+", "KLF15+", "PER1+"])
In R:
bq_track()
Record$add("dge_dex.csv")
bq_finish(finding = "Dexamethasone raised ZBTB16 and FKBP5 the most.",
genes = c("ZBTB16+", "FKBP5+"))
With an AI agent
An agent such as Claude Code can use baseqdb with your key. Ask it to start each task with baseqdb track
and end it with baseqdb finish: everything it runs in between is one run.
baseqdb track "Dexamethasone response in Airway"
python filter_counts.py --min-reads 10 # joins the run
python dge_dex.py --padj 0.01 # joins the run
baseqdb finish --finding "ZBTB16 and FKBP5 rose the most." \
--gene ZBTB16+ --gene FKBP5+
Data you fetch with a key leaves baSeq. Our Data Processing Agreement does not cover what an AI agent or another service then does with it.