LatchBio Integration
Overview
Latch is a Python framework for building and deploying bioinformatics workflows as serverless pipelines. Built on Flyte, create workflows with @workflow/@task decorators, manage cloud data with LatchFile/LatchDir, configure resources, and integrate Nextflow/Snakemake pipelines.
Core Capabilities
The Latch platform provides four main areas of functionality:
1. Workflow Creation and Deployment
- Define serverless workflows using Python decorators
- Support for native Python, Nextflow, and Snakemake pipelines
- Automatic containerization with Docker
- Auto-generated no-code user interfaces
- Version control and reproducibility
2. Data Management
- Cloud storage abstractions (LatchFile, LatchDir)
- Structured data organization with Registry (Projects → Tables → Records)
- Type-safe data operations with links and enums
- Automatic file transfer between local and cloud
- Glob pattern matching for file selection
3. Resource Configuration
- Pre-configured task decorators (@small_task, @large_task, @small_gpu_task, @large_gpu_task)
- Custom resource specifications (CPU, memory, GPU, storage)
- GPU support (K80, V100, A100)
- Timeout and storage configuration
- Cost optimization strategies
4. Verified Workflows
- Production-ready pre-built pipelines maintained by Latch
- Importable from the
latch.verified Python module: rnaseq, deseq2_wf, mafft, trim_galore, gene_ontology_pathway_analysis
- Many more pipelines (e.g. AlphaFold, single-cell, CRISPR) are available as Verified Workflows in the platform UI; verify the exact import name in
latch.verified before relying on a Python import (see references/verified-workflows.md)
Quick Start
Installation and Setup
# Install Latch SDK (uv-first; pip install latch also works)
uv pip install latch
# Login to Latch
latch login
# Initialize a new workflow (scaffolds wf/, Dockerfile, version)
latch init my-workflow
# Register workflow to platform (builds container, generates the UI)
latch register my-workflow
Prerequisites:
- Docker installed and running (registration builds a container locally)
- Latch account credentials
- Python 3.9+ (Latch SDK
requires-python >=3.9)
Basic Workflow Example
from latch import workflow, small_task
from latch.types import LatchFile
@small_task
def process_file(input_file: LatchFile) -> LatchFile:
"""Process a single file"""
# Processing logic
return output_file
@workflow
def my_workflow(input_file: LatchFile) -> LatchFile:
"""
My bioinformatics workflow
Args:
input_file: Input data file
"""
return process_file(input_file=input_file)
When to Use This Skill
This skill should be used when encountering any of the following scenarios:
Workflow Development:
- "Create a Latch workflow for RNA-seq analysis"
- "Deploy my pipeline to Latch"
- "Convert my Nextflow pipeline to Latch"
- "Add GPU support to my workflow"
- Working with
@workflow, @task decorators
Data Management:
- "Organize my sequencing data in Latch Registry"
- "How do I use LatchFile and LatchDir?"
- "Set up sample tracking in Latch"
- Working with
latch:/// paths
Resource Configuration:
- "Configure GPU for AlphaFold on Latch"
- "My task is running out of memory"
- "How do I optimize workflow costs?"
- Working with task decorators
Verified Workflows:
- "Run AlphaFold on Latch"
- "Use DESeq2 for differential expression"
- "Available pre-built workflows"
- Using
latch.verified module
Detailed Documentation
Load the reference that matches the task:
- references/workflow-creation.md —
latch init/latch register, @workflow/@task decorators, type annotations and docstrings (these populate the UI), launch plans, conditional sections, CLI/programmatic execution, parallel map_task, registration troubleshooting.
- references/data-management.md —
LatchFile/LatchDir and latch:/// paths, glob patterns, the Registry API (Project, Table, Record), column types, the table.update() transaction, and workflow-Registry integration.
- references/resource-configuration.md — standard task decorators,
@custom_task(cpu, memory, storage_gib, timeout), the GPU task decorators (small_gpu_task/large_gpu_task, v100_x{1,4,8}_task, g6e_*_task), and resource/cost right-sizing.
- references/verified-workflows.md — pipelines importable from
latch.verified and how to combine them with custom tasks.
Common Workflow Patterns
Complete RNA-seq Pipeline
from latch import workflow, small_task, large_task
from latch.types import LatchFile, LatchDir
@small_task
def quality_control(fastq: LatchFile) -> LatchFile:
"""Run FastQC"""
return qc_output
@large_task
def alignment(fastq: LatchFile, genome: str) -> LatchFile:
"""STAR alignment"""
return bam_output
@small_task
def quantification(bam: LatchFile) -> LatchFile:
"""featureCounts"""
return counts
@workflow
def rnaseq_pipeline(
input_fastq: LatchFile,
genome: str,
output_dir: LatchDir
) -> LatchFile:
"""RNA-seq analysis pipeline"""
qc = quality_control(fastq=input_fastq)
aligned = alignment(fastq=qc, genome=genome)
return quantification(bam=aligned)
GPU-Accelerated Workflow
from latch import workflow, small_task, large_gpu_task
from latch.types import LatchFile
@small_task
def preprocess(input_file: LatchFile) -> LatchFile:
"""Prepare data"""
return processed
@large_gpu_task
def gpu_computation(data: LatchFile) -> LatchFile:
"""GPU-accelerated analysis"""
return results
@workflow
def gpu_pipeline(input_file: LatchFile) -> LatchFile:
"""Pipeline with GPU tasks"""
preprocessed = preprocess(input_file=input_file)
return gpu_computation(data=preprocessed)
Registry-Integrated Workflow
from latch import workflow, small_task
from latch.registry.table import Table
@small_task
def process_and_track(sample_name: str, table_id: str) -> str:
"""Process a sample tracked in a Registry table and write status/result back."""
table = Table(table_id) # construct by id; no Table.get classmethod
# Find the record by name. list_records() yields pages of {record_id: Record}.
sample = None
for page in table.list_records():
for record in page.values():
if record.get_name() == sample_name:
sample = record
break
if sample is not None:
break
if sample is None:
raise ValueError(f"No record named {sample_name}")
# Read column values
values = sample.get_values()
input_file = values["fastq_file"] # a LatchFile for a 'file'-typed column
# ... processing logic produces an output LatchFile ...
# Write status/result back via the table.update() transaction (upsert by name)
with table.update() as updater:
updater.upsert_record(sample_name, status="completed", result=input_file)
return "Success"
@workflow
def registry_workflow(sample_name: str, table_id: str) -> str:
"""Workflow integrated with the Latch Registry."""
return process_and_track(sample_name=sample_name, table_id=table_id)
Best Practices
Workflow Design
- Use type annotations for all parameters
- Write clear docstrings (appear in UI)
- Start with standard task decorators, scale up if needed
- Break complex workflows into modular tasks
- Implement proper error handling
Data Management
- Use consistent folder structures
- Define Registry schemas before bulk entry
- Use linked records for relationships
- Store metadata in Registry for traceability
Resource Configuration
- Right-size resources (don't over-allocate)
- Use GPU only when algorithms support it
- Monitor execution metrics and optimize
- Design for parallel execution when possible
Development Workflow
- Test locally with Docker before registration
- Use version control for workflow code
- Document resource requirements
- Profile workflows to determine actual needs
Troubleshooting
Common Issues
Registration Failures:
- Ensure Docker is running
- Check authentication with
latch login
- Verify all dependencies in Dockerfile
- Use
--verbose flag for detailed logs
Resource Problems:
- Out of memory: Increase memory in task decorator
- Timeouts: Increase timeout parameter
- Storage issues: Increase ephemeral storage_gib
Data Access:
- Use correct
latch:/// path format
- Verify file exists in workspace
- Check permissions for shared workspaces
Type Errors:
- Add type annotations to all parameters
- Use LatchFile/LatchDir for file/directory parameters
- Ensure workflow return type matches actual return
Additional Resources
1---2name: alterlab-latchbio3description: Builds and deploys bioinformatics pipelines on the LatchBio platform using the Latch SDK — author workflows with @workflow/@task decorators, handle LatchFile/LatchDir I/O, register serverless workflows, configure CPU/GPU task resources, organize data in the Latch Registry, and wrap Nextflow/Snakemake pipelines. Use when developing or deploying a Latch SDK workflow, sizing task resources, working with the Registry, or porting a Nextflow/Snakemake bioinformatics pipeline onto LatchBio. Not for DNAnexus (dxpy/dx CLI) or generic Flyte. Part of the AlterLab Academic Skills suite.4license: MIT5---67# LatchBio Integration89## Overview1011Latch is a Python framework for building and deploying bioinformatics workflows as serverless pipelines. Built on Flyte, create workflows with @workflow/@task decorators, manage cloud data with LatchFile/LatchDir, configure resources, and integrate Nextflow/Snakemake pipelines.1213## Core Capabilities1415The Latch platform provides four main areas of functionality:1617### 1. Workflow Creation and Deployment18- Define serverless workflows using Python decorators19- Support for native Python, Nextflow, and Snakemake pipelines20- Automatic containerization with Docker21- Auto-generated no-code user interfaces22- Version control and reproducibility2324### 2. Data Management25- Cloud storage abstractions (LatchFile, LatchDir)26- Structured data organization with Registry (Projects → Tables → Records)27- Type-safe data operations with links and enums28- Automatic file transfer between local and cloud29- Glob pattern matching for file selection3031### 3. Resource Configuration32- Pre-configured task decorators (@small_task, @large_task, @small_gpu_task, @large_gpu_task)33- Custom resource specifications (CPU, memory, GPU, storage)34- GPU support (K80, V100, A100)35- Timeout and storage configuration36- Cost optimization strategies3738### 4. Verified Workflows39- Production-ready pre-built pipelines maintained by Latch40- Importable from the `latch.verified` Python module: `rnaseq`, `deseq2_wf`, `mafft`, `trim_galore`, `gene_ontology_pathway_analysis`41- Many more pipelines (e.g. AlphaFold, single-cell, CRISPR) are available as Verified Workflows in the platform UI; verify the exact import name in `latch.verified` before relying on a Python import (see references/verified-workflows.md)4243## Quick Start4445### Installation and Setup4647```bash48# Install Latch SDK (uv-first; pip install latch also works)49uv pip install latch5051# Login to Latch52latch login5354# Initialize a new workflow (scaffolds wf/, Dockerfile, version)55latch init my-workflow5657# Register workflow to platform (builds container, generates the UI)58latch register my-workflow59```6061**Prerequisites:**62- Docker installed and running (registration builds a container locally)63- Latch account credentials64- Python 3.9+ (Latch SDK `requires-python >=3.9`)6566### Basic Workflow Example6768```python69from latch import workflow, small_task70from latch.types import LatchFile7172@small_task73def process_file(input_file: LatchFile) -> LatchFile:74 """Process a single file"""75 # Processing logic76 return output_file7778@workflow79def my_workflow(input_file: LatchFile) -> LatchFile:80 """81 My bioinformatics workflow8283 Args:84 input_file: Input data file85 """86 return process_file(input_file=input_file)87```8889## When to Use This Skill9091This skill should be used when encountering any of the following scenarios:9293**Workflow Development:**94- "Create a Latch workflow for RNA-seq analysis"95- "Deploy my pipeline to Latch"96- "Convert my Nextflow pipeline to Latch"97- "Add GPU support to my workflow"98- Working with `@workflow`, `@task` decorators99100**Data Management:**101- "Organize my sequencing data in Latch Registry"102- "How do I use LatchFile and LatchDir?"103- "Set up sample tracking in Latch"104- Working with `latch:///` paths105106**Resource Configuration:**107- "Configure GPU for AlphaFold on Latch"108- "My task is running out of memory"109- "How do I optimize workflow costs?"110- Working with task decorators111112**Verified Workflows:**113- "Run AlphaFold on Latch"114- "Use DESeq2 for differential expression"115- "Available pre-built workflows"116- Using `latch.verified` module117118## Detailed Documentation119120Load the reference that matches the task:121122- **references/workflow-creation.md** — `latch init`/`latch register`, `@workflow`/`@task` decorators, type annotations and docstrings (these populate the UI), launch plans, conditional sections, CLI/programmatic execution, parallel `map_task`, registration troubleshooting.123- **references/data-management.md** — `LatchFile`/`LatchDir` and `latch:///` paths, glob patterns, the Registry API (`Project`, `Table`, `Record`), column types, the `table.update()` transaction, and workflow-Registry integration.124- **references/resource-configuration.md** — standard task decorators, `@custom_task(cpu, memory, storage_gib, timeout)`, the GPU task decorators (`small_gpu_task`/`large_gpu_task`, `v100_x{1,4,8}_task`, `g6e_*_task`), and resource/cost right-sizing.125- **references/verified-workflows.md** — pipelines importable from `latch.verified` and how to combine them with custom tasks.126127## Common Workflow Patterns128129### Complete RNA-seq Pipeline130131```python132from latch import workflow, small_task, large_task133from latch.types import LatchFile, LatchDir134135@small_task136def quality_control(fastq: LatchFile) -> LatchFile:137 """Run FastQC"""138 return qc_output139140@large_task141def alignment(fastq: LatchFile, genome: str) -> LatchFile:142 """STAR alignment"""143 return bam_output144145@small_task146def quantification(bam: LatchFile) -> LatchFile:147 """featureCounts"""148 return counts149150@workflow151def rnaseq_pipeline(152 input_fastq: LatchFile,153 genome: str,154 output_dir: LatchDir155) -> LatchFile:156 """RNA-seq analysis pipeline"""157 qc = quality_control(fastq=input_fastq)158 aligned = alignment(fastq=qc, genome=genome)159 return quantification(bam=aligned)160```161162### GPU-Accelerated Workflow163164```python165from latch import workflow, small_task, large_gpu_task166from latch.types import LatchFile167168@small_task169def preprocess(input_file: LatchFile) -> LatchFile:170 """Prepare data"""171 return processed172173@large_gpu_task174def gpu_computation(data: LatchFile) -> LatchFile:175 """GPU-accelerated analysis"""176 return results177178@workflow179def gpu_pipeline(input_file: LatchFile) -> LatchFile:180 """Pipeline with GPU tasks"""181 preprocessed = preprocess(input_file=input_file)182 return gpu_computation(data=preprocessed)183```184185### Registry-Integrated Workflow186187```python188from latch import workflow, small_task189from latch.registry.table import Table190191@small_task192def process_and_track(sample_name: str, table_id: str) -> str:193 """Process a sample tracked in a Registry table and write status/result back."""194 table = Table(table_id) # construct by id; no Table.get classmethod195196 # Find the record by name. list_records() yields pages of {record_id: Record}.197 sample = None198 for page in table.list_records():199 for record in page.values():200 if record.get_name() == sample_name:201 sample = record202 break203 if sample is not None:204 break205 if sample is None:206 raise ValueError(f"No record named {sample_name}")207208 # Read column values209 values = sample.get_values()210 input_file = values["fastq_file"] # a LatchFile for a 'file'-typed column211 # ... processing logic produces an output LatchFile ...212213 # Write status/result back via the table.update() transaction (upsert by name)214 with table.update() as updater:215 updater.upsert_record(sample_name, status="completed", result=input_file)216 return "Success"217218@workflow219def registry_workflow(sample_name: str, table_id: str) -> str:220 """Workflow integrated with the Latch Registry."""221 return process_and_track(sample_name=sample_name, table_id=table_id)222```223224## Best Practices225226### Workflow Design2271. Use type annotations for all parameters2282. Write clear docstrings (appear in UI)2293. Start with standard task decorators, scale up if needed2304. Break complex workflows into modular tasks2315. Implement proper error handling232233### Data Management2346. Use consistent folder structures2357. Define Registry schemas before bulk entry2368. Use linked records for relationships2379. Store metadata in Registry for traceability238239### Resource Configuration24010. Right-size resources (don't over-allocate)24111. Use GPU only when algorithms support it24212. Monitor execution metrics and optimize24313. Design for parallel execution when possible244245### Development Workflow24614. Test locally with Docker before registration24715. Use version control for workflow code24816. Document resource requirements24917. Profile workflows to determine actual needs250251## Troubleshooting252253### Common Issues254255**Registration Failures:**256- Ensure Docker is running257- Check authentication with `latch login`258- Verify all dependencies in Dockerfile259- Use `--verbose` flag for detailed logs260261**Resource Problems:**262- Out of memory: Increase memory in task decorator263- Timeouts: Increase timeout parameter264- Storage issues: Increase ephemeral storage_gib265266**Data Access:**267- Use correct `latch:///` path format268- Verify file exists in workspace269- Check permissions for shared workspaces270271**Type Errors:**272- Add type annotations to all parameters273- Use LatchFile/LatchDir for file/directory parameters274- Ensure workflow return type matches actual return275276## Additional Resources277278- Official Documentation: https://docs.latch.bio279- GitHub Repository (verify current API/decorator names here): https://github.com/latchbio/latch280- Support: support@latch.bio281