Transcriptomics
Differential expression, GEO dataset retrieval, and pathway analysis using direct tool calls and file upload/download.
Upload count matrix → DEG analysis → download results
Upload a raw count matrix CSV, run differential expression analysis, and download the ranked DEG table.
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
# 1. Upload count matrix (genes × samples)
upload = client.files.upload("counts.csv", workspace_id=ws_id, path="input/")
print(f"Uploaded: {upload['key']}")
# 2. Run DESeq2-style differential expression
deg = client.tools.run(
tool_id="deseq2_analysis",
input={
"file_path": upload["key"],
"workspace_id": ws_id,
"condition_col": "condition",
"reference_level": "control",
"treatment_level": "treated",
"padj_threshold": 0.05,
"log2fc_threshold": 1.0,
"output_path": "results/",
},
)
print(f"DEGs found: {deg['n_significant']}")
# 3. Download ranked DEG table
local = client.files.download(deg["output_path"], workspace_id=ws_id, dest="./output/")
print(f"Results saved to {local}")import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const [workspace] = await client.workspaces.list();
// 1. Upload count matrix
const upload = await client.files.upload('./counts.csv', {
workspaceId: workspace.id,
path: 'input/',
});
console.log('Uploaded:', upload.key);
// 2. Run DESeq2-style DEG analysis
const deg = await client.tools.run('deseq2_analysis', {
input: {
filePath: upload.key,
workspaceId: workspace.id,
conditionCol: 'condition',
referenceLevel: 'control',
treatmentLevel: 'treated',
padjThreshold: 0.05,
log2fcThreshold: 1.0,
outputPath: 'results/',
},
});
console.log('DEGs found:', deg.nSignificant);
// 3. Download results
const localPath = await client.files.download(deg.outputPath, workspace.id, './output/');
console.log('Results saved to', localPath);# 1. Upload count matrix
FILE_PATH=$(curl -s -X POST https://api.smarts.bio/v1/files/upload \
-H "Authorization: Bearer sk_live_..." \
-F "file=@counts.csv" -F "workspace_id=ws_abc123" -F "path=input/" \
| jq -r '.data.path')
# 2. Run DEG analysis
curl -s -X POST https://api.smarts.bio/v1/tools/deseq2_analysis/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"input": {"file_path": "'"$FILE_PATH"'", "workspace_id": "ws_abc123", "condition_col": "condition", "reference_level": "control", "treatment_level": "treated", "padj_threshold": 0.05, "log2fc_threshold": 1.0, "output_path": "results/"}}' \
| jq '{n_significant, output_path}'# 1. Upload count matrix (genes × samples) smarts file upload counts.csv --to input/ # 2. Run DESeq2-style differential expression smarts tool run deseq2_analysis \ --param file_path=input/counts.csv \ --param condition_col=condition \ --param reference_level=control \ --param treatment_level=treated \ --param padj_threshold=0.05 \ --param log2fc_threshold=1.0 \ --param output_path=results/ # 3. Download the ranked DEG table smarts file download results/ -o ./output/
Fetch a GEO dataset and run pathway enrichment
Download an RNA-seq dataset from GEO, then run KEGG pathway enrichment on the top DEGs.
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
# Step 1: fetch GEO dataset
geo = client.tools.run(
tool_id="geo_fetch",
input={
"accession": "GSE183947", # COVID-19 PBMC RNA-seq
"workspace_id": ws_id,
"output_path": "geo/",
},
)
print(f"Downloaded {geo['n_samples']} samples, {geo['n_genes']} genes")
# Step 2: KEGG pathway enrichment on top DEGs
gene_list = geo.get("top_degs", [])[:200]
enrichment = client.tools.run(
tool_id="kegg_enrichment",
input={"gene_list": gene_list, "species": "hsa", "pvalue_threshold": 0.05},
)
for p in enrichment["pathways"][:5]:
print(f" {p['name']} p={p['pvalue']:.2e} k={p['k']}/{p['n']}")
# Step 3: download enrichment results table
out = client.files.download(enrichment["output_path"], workspace_id=ws_id, dest="./")
print(f"Enrichment table saved to {out}")import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const [workspace] = await client.workspaces.list();
// Step 1: fetch GEO dataset
const geo = await client.tools.run('geo_fetch', {
input: { accession: 'GSE183947', workspaceId: workspace.id, outputPath: 'geo/' },
});
console.log(`Downloaded ${geo.nSamples} samples, ${geo.nGenes} genes`);
// Step 2: pathway enrichment
const geneList: string[] = (geo.topDegs ?? []).slice(0, 200);
const enrichment = await client.tools.run('kegg_enrichment', {
input: { geneList, species: 'hsa', pvalueThreshold: 0.05 },
});
enrichment.pathways.slice(0, 5).forEach((p: { name: string; pvalue: number; k: number; n: number }) => {
console.log(` ${p.name} p=${p.pvalue.toExponential(2)} k=${p.k}/${p.n}`);
});
// Step 3: download results
const out = await client.files.download(enrichment.outputPath, workspace.id, './');
console.log('Enrichment table saved to', out);# Step 1: fetch GEO dataset
TOP_DEGS=$(curl -s -X POST https://api.smarts.bio/v1/tools/geo_fetch/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"input": {"accession": "GSE183947", "workspace_id": "ws_abc123", "output_path": "geo/"}}' \
| jq '{n_samples, n_genes, top_degs: .top_degs[:200]}')
echo "GEO fetch result: $TOP_DEGS"
# Step 2: KEGG pathway enrichment on top DEGs
curl -s -X POST https://api.smarts.bio/v1/tools/kegg_enrichment/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"input": {"gene_list": ["BRCA1","TP53","EGFR","MYC","KRAS"], "species": "hsa", "pvalue_threshold": 0.05}}' \
| jq '.pathways[:5][] | {name, pvalue, k, n}'# Step 1: fetch GEO dataset (COVID-19 PBMC RNA-seq) smarts tool run geo_fetch \ --param accession=GSE183947 \ --param output_path=geo/ # Step 2: KEGG pathway enrichment on the top DEGs smarts tool run kegg_enrichment \ --param gene_list=BRCA1,TP53,EGFR,MYC,KRAS \ --param species=hsa \ --param pvalue_threshold=0.05 # Step 3: download the enrichment results table smarts file download geo/enrichment.csv -o ./
Isoform quantification from a BAM file
Upload a sorted BAM file, run isoform quantification, download the TPM matrix, then stream the agent's interpretation.
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
# 1. Upload sorted BAM + index
bam = client.files.upload("sample.bam", workspace_id=ws_id, path="bam/")
bai = client.files.upload("sample.bam.bai", workspace_id=ws_id, path="bam/")
# 2. Isoform quantification
quant = client.tools.run(
tool_id="rna_isoform_quant",
input={
"bam": bam["key"],
"bai": bai["key"],
"workspace_id": ws_id,
"genome": "GRCh38",
"gene_of_interest": "TP53",
"output_path": "quant/",
},
)
print(f"Isoforms detected: {quant['n_isoforms']}")
# 3. Download TPM matrix
local = client.files.download(quant["tpm_path"], workspace_id=ws_id, dest="./quant/")
print(f"TPM matrix saved to {local}")
# 4. Stream agent interpretation
for chunk in client.query.stream(
prompt=f"Interpret the TP53 isoform TPM results at {quant['tpm_path']}. Which isoforms are dominant?",
workspace_id=ws_id,
):
if chunk.type == "content":
print(chunk.content, end="", flush=True)import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const [workspace] = await client.workspaces.list();
// 1. Upload BAM + index
const bam = await client.files.upload('./sample.bam', { workspaceId: workspace.id, path: 'bam/' });
const bai = await client.files.upload('./sample.bam.bai', { workspaceId: workspace.id, path: 'bam/' });
// 2. Isoform quantification
const quant = await client.tools.run('rna_isoform_quant', {
input: {
bam: bam.key, bai: bai.key,
workspaceId: workspace.id, genome: 'GRCh38',
geneOfInterest: 'TP53', outputPath: 'quant/',
},
});
console.log('Isoforms detected:', quant.nIsoforms);
// 3. Download TPM matrix
const localPath = await client.files.download(quant.tpmPath, workspace.id, './quant/');
console.log('TPM matrix saved to', localPath);
// 4. Stream agent interpretation
for await (const chunk of client.query.stream({
prompt: `Interpret the TP53 isoform TPM results at ${quant.tpmPath}. Which isoforms are dominant?`,
workspaceId: workspace.id,
})) {
if (chunk.type === 'content') process.stdout.write(chunk.content ?? '');
}# 1. Upload BAM + index
BAM_PATH=$(curl -s -X POST https://api.smarts.bio/v1/files/upload \
-H "Authorization: Bearer sk_live_..." \
-F "file=@sample.bam" -F "workspace_id=ws_abc123" -F "path=bam/" \
| jq -r '.data.path')
BAI_PATH=$(curl -s -X POST https://api.smarts.bio/v1/files/upload \
-H "Authorization: Bearer sk_live_..." \
-F "file=@sample.bam.bai" -F "workspace_id=ws_abc123" -F "path=bam/" \
| jq -r '.data.path')
# 2. Run isoform quantification
TPM_PATH=$(curl -s -X POST https://api.smarts.bio/v1/tools/rna_isoform_quant/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d "{\"input\": {\"bam\": \"$BAM_PATH\", \"bai\": \"$BAI_PATH\", \"workspace_id\": \"ws_abc123\", \"genome\": \"GRCh38\", \"gene_of_interest\": \"TP53\", \"output_path\": \"quant/\"}}" \
| jq -r '.tpm_path')
# 3. Stream agent interpretation
curl -N -X POST https://api.smarts.bio/v1/query/stream \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d "{\"prompt\": \"Interpret the TP53 isoform TPM results at $TPM_PATH. Which isoforms are dominant?\", \"workspace_id\": \"ws_abc123\"}"# 1. Upload sorted BAM + index smarts file upload sample.bam --to bam/ smarts file upload sample.bam.bai --to bam/ # 2. Isoform quantification smarts tool run rna_isoform_quant \ --param bam=bam/sample.bam \ --param bai=bam/sample.bam.bai \ --param genome=GRCh38 \ --param gene_of_interest=TP53 \ --param output_path=quant/ # 3. Download the TPM matrix smarts file download quant/ -o ./quant/ # 4. Stream the agent's interpretation smarts query "Interpret the TP53 isoform TPM results at quant/. \ Which isoforms are dominant?"