### Install Jasmine via Bioconda (Bash) Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Provides instructions for installing the Jasmine tool using Bioconda. It covers creating a dedicated conda environment, activating it, verifying the installation, and adding it to an existing environment. Docker usage is also included. ```bash # Create dedicated conda environment for jasmine conda create -n jasmine -c bioconda pbjasmine conda activate jasmine # Verify installation jasmine --version # Should output: jasmine 2.4.0 # Alternative: add to existing environment conda install -c bioconda pbjasmine # Docker usage (if using PacBio containers) docker pull pacbio/jasmine:2.4.0 docker run -v $(pwd):/data pacbio/jasmine:2.4.0 \ jasmine /data/input.bam /data/output.bam ``` -------------------------------- ### View Complete Read with Methylation Tags Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Displays a complete read entry from a BAM file, including all associated tags, with a focus on identifying methylation information. This uses `samtools view` and `head -1` to extract the first read's details. ```bash samtools view movie.methylation.hifi_reads.bam | head -1 ``` -------------------------------- ### Extract Required Kinetic Tags Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Extracts and displays the first four required kinetic tags (fp, fi, rp, ri) from a HiFi reads BAM file. This uses `samtools view` and `awk` to filter and format the output, providing a clear view of the kinetic data for each read. ```bash samtools view movie.hifi_reads.bam | \ awk '{for(i=12;i<=NF;i++) if($i~/^(fp|fi|rp|ri):/) print $i}' | \ head -4 ``` -------------------------------- ### Verify Kinetics Tags Presence Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Verifies if the required kinetic tags (fp, fi, rp, ri) are present in the generated HiFi reads BAM file. This uses `samtools view` to inspect the header of the BAM file and `grep` to search for the tags. This step is crucial for ensuring downstream analysis can proceed. ```bash samtools view movie.hifi_reads.bam | head -1 | grep -o "fp:B.*" ``` -------------------------------- ### Execute Jasmine for Base Modification Calling Source: https://github.com/pacificbiosciences/jasmine/blob/main/README.md This command executes the jasmine tool to call base modifications in PacBio HiFi reads. It takes the input BAM file containing HiFi reads with kinetics and an output BAM file where methylation information will be stored. The tool analyzes polymerase kinetic signatures to identify modifications like 5mC and 6mA. ```bash jasmine movie.hifi_reads.bam movie.methylation.hifi_reads.bam ``` -------------------------------- ### Run Jasmine for 5mC and 6mA Detection (Bash) Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Basic command-line usage for detecting 5-Methylcytosine (5mC) and N6-Methyladenine (6mA) from PacBio HiFi BAM files. Supports processing multiple SMRT cells and typical workflows involving sorting and indexing. ```bash # Simple 5mC and 6mA detection from HiFi BAM input jasmine movie.hifi_reads.bam movie.methylation.hifi_reads.bam # Process multiple SMRT cells jasmine movie1.hifi_reads.bam output1.methylation.bam jasmine movie2.hifi_reads.bam output2.methylation.bam # Typical workflow with sorted and indexed output jasmine input.hifi_reads.bam output.methylation.bam samtools sort -o output.methylation.sorted.bam output.methylation.bam samtools index output.methylation.sorted.bam ``` -------------------------------- ### Generate HiFi Reads with Kinetics Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Generates HiFi reads from a BAM file, including kinetic information required for methylation analysis. This process uses the `ccs` tool with the `--hifi-kinetics` flag. Ensure the input BAM file is correctly formatted. ```bash ccs movie.subreads.bam movie.hifi_reads.bam \ --hifi-kinetics ``` -------------------------------- ### Parse MM and ML Tags from BAM File (Python) Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Parses the `MM` and `ML` tags from a BAM file generated by Jasmine using the `pysam` library. This demonstrates how to extract modification type, positions, and probabilities for downstream analysis. ```python # Parse MM and ML tags from pysam import pysam bam = pysam.AlignmentFile("movie.methylation.hifi_reads.bam", "rb") for read in bam: mm_tag = read.get_tag("MM") # e.g., "C+m,3,1,0,2,5" ml_tag = read.get_tag("ML") # e.g., [249, 4, 128, 200, 15] # Example read sequence with CpG sites # Read AGTCTAGACTCCGTAATTACTCGCCTAG # C 1 2 34 5 6 78 # CpG * * # # MM:Z:C+m,3,1,... indicates: # - Modification type: C+m (5mC on cytosine) # - First CpG at position 4 (skip 3 C's, then modified C at index 1+3) # - Second CpG at position 6 (skip 1 more C, then modified) # # ML:B:C,249,4,... indicates: # - First CpG: probability in [249/256, 250/256) = ~97.3% methylated # - Second CpG: probability in [4/256, 5/256) = ~1.6% methylated # Extract high-confidence methylated CpGs (>50% probability) def get_methylated_cpgs(read, threshold=128): mm = read.get_tag("MM") ml = read.get_tag("ML") methylated_positions = [] cumulative_pos = 0 if mm.startswith("C+m,"): skips = [int(x) for x in mm.split(",")[1:]] for skip, prob in zip(skips, ml): cumulative_pos += skip + 1 if prob > threshold: methylated_positions.append(cumulative_pos) return methylated_positions bam.close() ``` -------------------------------- ### Extract Methylation Information Tags Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Extracts and prints only the methylation-related tags (MM and ML) from a BAM file. This command uses `samtools view` and `awk` to filter lines containing these specific tags, making it easier to inspect methylation data. ```bash samtools view movie.methylation.hifi_reads.bam | \ awk '{for(i=1;i<=NF;i++) if($i~/^MM:|^ML:/) printf "%s\t",$i; print ""}' ``` -------------------------------- ### Run Jasmine for Fiber-seq 6mA Detection (Bash) Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Executes Jasmine on Fiber-seq HiFi data for strand-specific adenine methylation calling. It also shows how to extract 6mA calls compatible with `fibertools` for downstream analysis. ```bash # Run jasmine on Fiber-seq HiFi data jasmine fiberseq.hifi_reads.bam fiberseq.methylation.bam # Extract 6mA calls compatible with fibertools # The output contains MM:Z:A+a tag for 6mA modifications samtools view fiberseq.methylation.bam | head -1 # Example output read with 6mA: # Read ATGCAATAGCATAAACGATCGAT # A * ** *** * # # MM:Z:A+a,0,2,0,0,2,0,0,0 # 6mA positions marked with skip counts # ML:B:C,230,245,198,210,180,220,195,185 # Probabilities for each marked A # Integration with fibertools for downstream analysis fibertools extract -a fiberseq.methylation.bam > accessible_regions.bed fibertools fire fiberseq.methylation.bam > fire_elements.bed ``` -------------------------------- ### Convert BAM to bedMethyl for IGV Visualization Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Converts a PacBio BAM file containing MM and ML tags to the bedMethyl (bedGraph) format. This format is suitable for visualization in genome browsers like IGV, displaying methylation levels. It requires the pysam library for BAM file handling. ```python import pysam def bam_to_bedmethyl(bam_path, output_bed): bam = pysam.AlignmentFile(bam_path, "rb") with open(output_bed, "w") as bed: bed.write("track type=bedGraph name=Methylation\n") for read in bam: if not read.has_tag("MM"): continue ref_pos = read.reference_start mm = read.get_tag("MM") ml = read.get_tag("ML") if "C+m" in mm: skips = [int(x) for x in mm.split(",")[1:]] pos = ref_pos for skip, prob in zip(skips, ml): pos += skip prob_pct = int((prob / 255.0) * 100) bed.write(f"{read.reference_name}\t{pos}\t{pos+1}\t{prob_pct}\n") pos += 1 bam.close() bam_to_bedmethyl("input.bam", "methylation.bedgraph") ``` -------------------------------- ### Python Quality Control for Methylation Calls Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Performs quality control on methylation calls using Python and the `pysam` library. This function analyzes a BAM file to calculate 5mC and 6mA call rates and interprets them based on expected sample types (human WGS, human fiber-seq, PCR amplicon), helping to detect potential false positives or issues with the data. ```python import pysam import numpy as np def qc_methylation_calls(bam_path, sample_type="human_wgs"): """ QC methylation calls based on expected sample characteristics. Args: sample_type: "human_wgs", "human_fiberseq", "pcr_amplicon" """ bam = pysam.AlignmentFile(bam_path, "rb") cpg_calls = [] m6a_calls = [] for read in bam: if read.has_tag("MM") and read.has_tag("ML"): mm = read.get_tag("MM") ml = read.get_tag("ML") # Count high-confidence calls (>50% = >128/255) high_conf = [p > 128 for p in ml] if "C+m" in mm: cpg_calls.extend(high_conf) elif "A+a" in mm: m6a_calls.extend(high_conf) cpg_rate = np.mean(cpg_calls) if cpg_calls else 0 m6a_rate = np.mean(m6a_calls) if m6a_calls else 0 # Expected methylation rates from ACCURACY.md examples print(f"Sample: {sample_type}") print(f"5mC at CpG call rate: {cpg_rate:.1%}") print(f"6mA call rate: {m6a_rate:.1%}") # Interpret results if sample_type == "human_wgs": # Expected: 5mC ~60%, 6mA ~0.6% (FPR baseline) if m6a_rate > 0.02: # >2% suggests real 6mA signal print("⚠️ Elevated 6mA detected in WGS (unexpected)") else: print("✓ 6mA at FPR baseline (no functional 6mA in humans)") elif sample_type == "human_fiberseq": # Expected: 5mC ~55%, 6mA ~10% if m6a_rate < 0.02: print("⚠️ Low 6mA in Fiber-seq (possible library issue)") else: print("✓ 6mA well above FPR (good Fiber-seq signal)") elif sample_type == "pcr_amplicon": # Expected: Both at FPR (~7% 5mC, ~0.6% 6mA) if cpg_rate > 0.15 or m6a_rate > 0.02: print("⚠️ Unexpected methylation in PCR amplicon") bam.close() return cpg_rate, m6a_rate # Example usage qc_methylation_calls("human_wgs.methylation.bam", "human_wgs") # Output: # Sample: human_wgs # 5mC at CpG call rate: 59.7% # 6mA call rate: 0.6% # ✓ 6mA at FPR baseline (no functional 6mA in humans) qc_methylation_calls("fiberseq.methylation.bam", "human_fiberseq") # Output: # Sample: human_fiberseq # 5mC at CpG call rate: 55.0% # 6mA call rate: 9.7% # ✓ 6mA well above FPR (good Fiber-seq signal) ``` -------------------------------- ### Interpret SMRT Cell Methylation Reports Source: https://context7.com/pacificbiosciences/jasmine/llms.txt Parses methylation summary data from Revio/Vega SMRT Cell reports, interpreting fractions of CpG and 6mA methylated sites. This function assesses QC pass/fail and provides notes based on expected ranges for different sample types like human WGS, Fiber-seq, and RNA. It takes CpG fraction, m6a fraction, and sample type as input. ```python # Parse methylation summary from Revio/Vega SMRT Cell reports # Reports show fraction of sites with >50% probability calls def interpret_smrt_cell_report(cpg_fraction, m6a_fraction, sample_type): """ Interpret Methylation Summary from SMRT Cell QC report. Args: cpg_fraction: Fraction of CpG sites called methylated (e.g., 0.597) m6a_fraction: Fraction of A sites called methylated (e.g., 0.006) sample_type: Expected sample characteristics Returns: dict with QC status and interpretation """ report = { "5mC_at_CpG": f"{cpg_fraction:.1%}", "6mA": f"{m6a_fraction:.1%}", "qc_pass": True, "notes": [] } # Reference examples from ACCURACY.md: # Human WGS (Revio 13.3): 5mC=59.7%, 6mA=0.6% # Human Fiber-seq (Revio 13.3): 5mC=55.0%, 6mA=9.7% # Kinnex RNA (Revio 13.3): 5mC=6.7%, 6mA=0.6% if sample_type == "human_wgs": if cpg_fraction < 0.40 or cpg_fraction > 0.75: report["qc_pass"] = False report["notes"].append("5mC out of expected range for human WGS") if m6a_fraction > 0.02: report["notes"].append("6mA elevated above FPR baseline") else: report["notes"].append("6mA at FPR - no evidence of 6mA in sample") elif sample_type == "fiber_seq": if m6a_fraction < 0.05: report["qc_pass"] = False report["notes"].append("6mA below expected for Fiber-seq") else: report["notes"].append("6mA well above FPR - good evidence in sample") elif sample_type == "rna": if cpg_fraction > 0.10 or m6a_fraction > 0.02: report["notes"].append("Methylation near/at FPR baseline") else: report["notes"].append("No evidence of methylation (expected for RNA)") return report # Example usage with real SMRT Cell data result = interpret_smrt_cell_report(0.597, 0.006, "human_wgs") print(result) # Output: # { # '5mC_at_CpG': '59.7%', # '6mA': '0.6%', # 'qc_pass': True, # 'notes': ['6mA at FPR - no evidence of 6mA in sample'] # } result = interpret_smrt_cell_report(0.550, 0.097, "fiber_seq") print(result) # Output: # { # '5mC_at_CpG': '55.0%', # '6mA': '9.7%', # 'qc_pass': True, # 'notes': ['6mA well above FPR - good evidence in sample'] # } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.