Skip to main content

30-Second Command Line Analysis

Analyze your heart data with a single command:
heartmap your_heart_data.h5ad
That’s it! HeartMAP will:
  • Automatically detect your data format
  • Perform quality control
  • Run cell type annotation
  • Generate visualizations
  • Save results to ./results/
This uses default settings optimized for typical heart datasets. For custom analysis, see the 2-minute Python example below.

2-Minute Python Analysis

For more control, use the Python API:
from heartmap import Config
from heartmap.pipelines import ComprehensivePipeline

# Quick analysis with defaults
config = Config.default()
pipeline = ComprehensivePipeline(config)
results = pipeline.run('your_data.h5ad', 'results/')

print("✓ Analysis complete! Check 'results/' directory.")
What you get:
  • Cell type clusters and annotations
  • Quality control metrics and plots
  • UMAP visualization
  • Comprehensive analysis report
  • Processed AnnData object saved for further analysis

Custom Output Directory

# CLI
heartmap your_data.h5ad --output-dir my_results/

# Python
results = pipeline.run('your_data.h5ad', 'my_results/')

Choose Analysis Type

Runtime: 5-10 minutes | Best for: Quick QC and cell typing
heartmap your_data.h5ad --analysis-type annotation
from heartmap.pipelines import BasicPipeline

pipeline = BasicPipeline(config)
results = pipeline.run('your_data.h5ad', 'results/')
Outputs:
  • Cell type clusters (Leiden clustering)
  • QC metrics (mitochondrial genes, cell counts)
  • UMAP plot colored by cluster
  • Marker genes per cluster

Memory-Optimized Analysis

If you have limited RAM (8-16GB), use a custom config:
from heartmap import Config

# Create memory-optimized config
config = Config.default()
config.data.max_cells_subset = 10000  # Analyze 10K cells
config.data.max_genes_subset = 2000   # Top 2K variable genes

pipeline = ComprehensivePipeline(config)
results = pipeline.run('large_dataset.h5ad', 'results/')
Memory Guidelines:
  • 8GB RAM: max_cells_subset = 10000, max_genes_subset = 2000
  • 16GB RAM: max_cells_subset = 30000, max_genes_subset = 4000
  • 32GB+ RAM: max_cells_subset = 50000, max_genes_subset = 5000

Using Custom Config File

# Create your config
cat > my_config.yaml << EOF
data:
  min_genes: 200
  min_cells: 3
  max_cells_subset: 30000
  max_genes_subset: 4000

analysis:
  resolution: 0.5
  n_neighbors: 10
  use_leiden: true
EOF

# Run with custom config
heartmap your_data.h5ad --config my_config.yaml
# Python
config = Config.from_yaml('my_config.yaml')
pipeline = ComprehensivePipeline(config)
results = pipeline.run('your_data.h5ad', 'results/')

Working with Results

After analysis, explore your results:
import scanpy as sc

# Load processed data
adata = sc.read_h5ad('results/heartmap_complete.h5ad')

# View cell clusters
print(adata.obs['leiden'].value_counts())

# Access hub scores (from communication analysis)
if 'hub_score' in adata.obs:
    print(f"Average hub score: {adata.obs['hub_score'].mean():.4f}")

# Plot specific genes
sc.pl.umap(adata, color=['NPPA', 'MYH7', 'CD36'])

Expected Outputs

After running quick analysis, you’ll find:
results/
├── figures/
│   ├── umap_clusters.png          # Cell type visualization
│   ├── qc_metrics.png              # Quality control plots
│   └── marker_genes.png            # Top markers per cluster
├── tables/
│   ├── cluster_summary.csv         # Cluster statistics
│   └── marker_genes.csv            # Marker gene list
├── heartmap_complete.h5ad          # Processed AnnData
└── analysis_report.html            # Interactive report

Troubleshooting

Reduce dataset size:
config.data.max_cells_subset = 5000
config.data.max_genes_subset = 1000
Use absolute paths:
from pathlib import Path
data_path = Path('/full/path/to/your_data.h5ad')
results = pipeline.run(str(data_path), 'results/')
Enable test mode for quick validation:
config.data.test_mode = True  # Uses small subset

Next Steps

Python API

Explore comprehensive API examples

Custom Pipelines

Build your own analysis workflows

Configuration

Learn about all configuration options

Output Reference

Understand all output files

Build docs developers (and LLMs) love