xiaohongshu
xiaohongshu
global-methylation-profile
This skill performs genome-wide DNA methylation profiling. It supports single-sample and multi-sample workflows to compute methylation density distributions, genomic feature distribution of the methylation profile, and sample-level clustering/PCA. Use it when you want to systematically characteri...
Full skill instructions
Main steps include:
Use the global-methylation-profiling skill when you want to:
<sample.bed
global_methylation_profile/
stats/
summary_statistics.tsv
...
plots/
sample1_genomic_feature_pie.pdf
sample2_genomic_feature_pie.pdf
... # Other samples
allSamples_methylation_density_overlay.pdf
PCA_scatterplot.pdf
sample_correlation_heatmap.pdf
...
logs/
temp/ # all the temp files
library(methylKit)
# Example input: Bismark coverage files (chr, start, end, numCs, numTs, strand)
file.list <- list(
"sample1.cov",
"sample2.cov",
"sample3.cov"
)
sample.id <- list("S1", "S2", "S3")
treatment <- c(0, 1, 1) # e.g. 0 = control, 1 = treated
# Read methylation data
myobj <- methRead(
location = file.list,
sample.id = sample.id,
assembly = "hg38", # provided by user
treatment = treatment,
context = "CpG",
pipeline = list(
fraction = FALSE, # percMeth is 0–100, fraction is 0-1, depend on inputs
chr.col = 1,
start.col = 2,
end.col = 3,
strand.col = 6, # provided by user
coverage.col = 10, # provided by user
freqC.col = 11 # provided by user
)
)
# Optional filtering: remove low / extremely high coverage CpGs
filtered.myobj <- filterByCoverage(
myobj,
lo.count = 10, lo.perc = NULL,
hi.count = 99.9, hi.perc = TRUE
)
# Unite CpGs across samples (common CpG sites)
meth <- unite(filtered.myobj, destrand = TRUE)
Annotate CpGs with genomic features (promoter, exon, intron, intergenic, etc.) with genomation and summarize where CpGs (or methylated CpGs) are located for each sample
library(genomation)
library(TxDb.Hsapiens.UCSC.hg38.knownGene) # depend on user inputs
txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene
# exons
exons <- unlist(exonsBy(txdb))
names(exons) <- NULL
mcols(exons)$type <- "exon"
# introns
introns <- unlist(intronsByTranscript(txdb))
names(introns) <- NULL
mcols(introns)$type <- "intron"
# promoters
promoters.gr <- promoters(txdb, upstream = 2000, downstream = 200)
names(promoters.gr) <- NULL
mcols(promoters.gr)$type <- "promoter"
# TSS(1bp)
TSSes <- promoters(txdb, upstream = 1, downstream = 1)
names(TSSes) <- NULL
mcols(TSSes)$type <- "TSS"
# 3'UTR
utr3 <- unlist(threeUTRsByTranscript(txdb))
names(utr3) <- NULL
mcols(utr3)$type <- "UTR3"
# 5'UTR
utr5 <- unlist(fiveUTRsByTranscript(txdb))
names(utr5) <- NULL
mcols(utr5)$type <- "UTR5"
gene.obj <- GRangesList(
promoters = promoters.gr,
exons = exons,
introns = introns,
TSSes = TSSes
UTR5 = utr5,
UTR3 = utr3,
... # other features
)
for (i in seq_along(filtered.myobj)) {
sample_id <- filtered.myobj[[i]]@sample.id
cpg.gr <- as(filtered.myobj[[i]], "GRanges")
ann.gene <- annotateWithGeneParts(cpg.gr, gene.obj)
feature.summary <- getTargetAnnotationStats(ann.gene, percentage = TRUE)
out_tab <- as.data.frame(feature.summary)
write.table(
out_tab,
file = file.path(plot_dir, paste0(sample_id, "_feature_annotation_stats.tsv")),
sep = "\t", quote = FALSE, row.names = FALSE
)
pdf(file.path(plot_dir, paste0(sample_id, "_genomic_feature_distribution.pdf")))
plotTargetAnnotation(
ann.gene,
main = paste("Genomic feature distribution of CpGs -", sample_id)
)
dev.off()
}
Step 3: Compute & visualize genome-wide methylation density distributions
# Convert to percent methylation matrix: rows = CpGs, cols = samples
meth.mat <- percMethylation(meth) # values 0–100
df.long <- reshape2::melt(
as.data.frame(meth.mat),
variable.name = "Sample",
value.name = "Methylation"
)
ggplot(df.long, aes(x = Methylation, color = Sample)) +
geom_density() +
theme_bw() +
xlab("Percent methylation") +
ggtitle("Genome-wide methylation density across samples")
# Meth matrix: rows = CpGs, cols = samples (0–100)
meth.mat <- percMethylation(meth)
# (Optional) Filter CpGs by variability
cpg.sd <- apply(meth.mat, 1, sd, na.rm = TRUE)
keep.var <- cpg.sd > 0
meth.var <- meth.mat[keep.var, ]
if (sum(keep.var) > 10000) {
keep.idx <- order(cpg.sd[keep.var], decreasing = TRUE)[1:10000]
meth.var <- meth.var[keep.idx, ]
}
# Z-score transformation (per CpG) – helps clustering
meth.scaled <- t(scale(t(meth.var))) # rows scaled
pca <- prcomp(t(meth.scaled), center = FALSE, scale. = FALSE)
pca.df <- data.frame(
Sample = colnames(meth.scaled),
PC1 = pca$x[, 1],
PC2 = pca$x[, 2],
Treatment = factor(treatment, labels = c("Control", "Treatment"))
)
ggplot(pca.df, aes(x = PC1, y = PC2, color = Treatment, label = Sample)) +
geom_point(size = 3) +
geom_text(vjust = -1) +
theme_bw() +
ggtitle("PCA of global CpG methylation") +
xlab(paste0("PC1 (", round(summary(pca)$importance[2, 1] * 100, 1), "%)")) +
ylab(paste0("PC2 (", round(summary(pca)$importance[2, 2] * 100, 1), "%)"))
dist.samples <- dist(t(meth.scaled), method = "euclidean")
hc <- hclust(dist.samples, method = "complete")
plot(hc, main = "Hierarchical clustering of samples (methylation)",
xlab = "", sub = "")
cor.samples <- cor(meth.var, use = "pairwise.complete.obs")
pheatmap(cor.samples,
clustering_method = "complete",
main = "Sample correlation based on CpG methylation")
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience