1000genomes
A mirror of selected genomic datasets from the 1000 Genomes Project.
This database mirrors some of the datasets of the 1000 Genomes Project in .parquet format. It was created alongside this blog post: https://blog.lamin.ai/1000genomes
Basic analyses
There are two collections in the database.
| Observations | Grouping | Rows | Files | Explore |
|---|---|---|---|---|
| CNVs | Per-individual | 4.86M | 3201 | link |
| CNVs, SNVs, Indels | Per-chromosome | 88M | 26 | link |
import lamindb as ln
import polars as pl
# Connect to the instance
db = ln.DB("laminlabs/1000genomes")
# Retrieve the collection of parquet files
collection = db.Collection.get("hVu9puwdRGskm1I6")
# Confirm the schema contract for these files
collection.schema.describe()
Simple Filter
Filter variants on a chromosome within a position band and show results by type:
chrom = "1"
lo, hi = 150_000_000, 200_000_000
with collection.open(engine="polars") as df:
filtered = df.filter(
(pl.col("chrom") == chrom) & (pl.col("pos") >= lo) & (pl.col("pos") <= hi)
).collect()
# breakdown by variant type, for context
by_type = (
filtered.group_by("variant_type")
.agg(pl.len().alias("n"))
.sort("n", descending=True)
)
print(by_type)
Summary Statistics
Calculate the total variant count, deletions, insertions, and mean allele frequencies:
with collection.open(engine="polars") as df:
stats = (
df.group_by("chrom").agg(
pl.len().alias("Total_Variants"),
(pl.col("variant_type") == "DEL").sum().alias("Deletions"),
(pl.col("variant_type") == "INS").sum().alias("Insertions"),
pl.col("af").mean().alias("Mean_AF"),
pl.col("eur_af").mean().alias("Mean_EUR_AF"),
).sort("chrom").collect()
)
Recurrent Regions
Identify genomic regions with multiple variants by binning positions into 1 Mbp windows:
with collection.open(engine="polars") as df:
recurrent = (
df.with_columns(
(pl.col("chrom").cast(pl.Utf8) + ":" +
((pl.col("pos") // 1000000) * 1000000).cast(pl.Utf8)).alias("region_key")
)
.group_by("region_key").agg(pl.len().alias("variant_count"))
.filter(pl.col("variant_count") >= 2)
.sort("variant_count", descending=True).collect()
)
Reproduce user journeys
To reproduce the user journeys from the blog post, you'll need to lamin load the bench_utils.py script into your development directory:
lamin load https://lamin.ai/laminlabs/1000genomes/transform/RRBbk27qAOzU
You can then find the notebooks for the user journeys in the analysis/ folder under Transforms.