Package: nanomotif
NanomotifNanomotif is a Python package that provides functionality for identifying methylation motifs on references using Nanopore sequencing.InstallationLocal EnvironmentTo install Nanomotif in a local Python environment:python3-mvenvnanomotifsourcenanomotif/bin/activate
pipinstallnanomotifConda EnvironmentIf you prefer using Conda for managing your Python environments, you can create a new environment and install Nanomotif as follows:condacreate-nnanomotifpython=3.9
condaactivatenanomotif
python-mpipinstallnanomotifCheck installationOnce installed, the installation can be checked by running:nanomotifcheck-installationThis runs a test run on a small dataset, ensuring everything works.Required filesTo identify methylated motifs, the following files are required:Assemblymethylation pileupContig-bin relationship**Only for bin-consensus (and by extension, complete-workflow)AssemblyAssembly from any assembler can be used. Nanomotif was developed using assemblies made withmetaFlyeMethylation pileupGenerated using ONTmodkit. Assembly and basecalls with methylations are required.OBS: when demultiplexing, trimming of reads may result in errors downstream. We therefore recommend using untrimmed reads for mappingsamtoolsfastq-TMM,ML{DORADO_BASECALLS.sam}|\minimap2-axmap-ont-y{ASSEMBLY.fasta}-|\samtoolsview-bS|\samtoolssort-o{ALIGNMENT.bam}modkitpileup--only-tabs{ALIGNMENT.bam}{OUT.bed}Contig-binFile describing which contigs belongs to which bins. It should be headerless, tab-separated file with contig id in the first column and bin in the second column. If the bins are outputted in a folder with one fasta file pr. bin, the contig-bin file can be generated using the following snippet:BINS=/path/to/bins    # Bin directory
EXT="fa"              # Filename extension
grep ">" ${BINS}/*.${EXT} | \
        sed "s/.*\///" | \
        sed "s/.${EXT}:>/\t/" | \
        awk -F'\t' '{print $2 "\t" $1}' > contig_bin.tsvUsageusage: nanomotif [-h] [--version] {find-motifs,score-motifs,bin-consensus,complete-workflow,check-installation} ...

Motif identification and utilisation commands

positional arguments:
                        Command descriptions
    find-motifs         identifies motifs in contigs
    score-motifs        generate feature complete output (all identified motifs have an entry for all contigs)
    bin-consensus       generate consensus set of motif for each bin
    complete-workflow   run find-motifs, score-motifs and bin-consensusMonocultureIf you are interested in finding methylated motifs in a monoculture sample, we recomment just runningfind-motifs.nanomotif find-motifs ASSEMBLY.fasta PILEUP.bedMetagenomic sampleIf you have metagenomic sample with multiple organims, we recommend runningcomplete-workflownanomotif complete-workflow ASSEMBLY.fasta PILEUP.bed CONTIG_BIN.tsvHelpHelp page ofcomplete-workflowcontains description of all argumentsusage: nanomotif complete-workflow [-h] [--out OUT] [-t THREADS] [-v] [--seed SEED] [--threshold_methylation_general THRESHOLD_METHYLATION_GENERAL]
                                   [--search_frame_size SEARCH_FRAME_SIZE] [--threshold_methylation_confident THRESHOLD_METHYLATION_CONFIDENT]
                                   [--threshold_valid_coverage THRESHOLD_VALID_COVERAGE] [--minimum_kl_divergence MINIMUM_KL_DIVERGENCE]
                                   assembly pileup bins
positional arguments:
  assembly              path to the assembly file.
  pileup                path to the modkit pileup file.
  bins                  tsv file specifying which bin contigs belong.

optional arguments:
  -h, --help            show this help message and exit
  --out OUT             path to the output folder
  -t THREADS, --threads THREADS
                        number of threads to use. Default is 1
  -v, --verbose         increase output verbosity. (set logger to debug level)
  --seed SEED           seed for random number generator. Default: 1
  --threshold_methylation_general THRESHOLD_METHYLATION_GENERAL
                        minimum fraction of reads that must be methylated at a position for the position to be methylated. These position are used for counting number of
                        methylated position of a motif. Default: 0.6
  --search_frame_size SEARCH_FRAME_SIZE
                        length of the sequences sampled around confident methylation sites. Default: 40
  --threshold_methylation_confident THRESHOLD_METHYLATION_CONFIDENT
                        minimum fraction of reads that must be methylated at a position for the position to be considered confiently methylated. These position are used to
                        search for candidate motifs. Default: 0.8
  --threshold_valid_coverage THRESHOLD_VALID_COVERAGE
                        minimum valid base coverage for a position to be considered. Default: 5
  --minimum_kl_divergence MINIMUM_KL_DIVERGENCE
                        minimum KL-divergence for a position to considered for expansion in motif search. Higher value means less exhaustive, but faster search. Default: 0.2Output descriptionfind-motifs and score-motifsfind-motifsoutputs results tomotifs.tsvandscore-motifsoutputs result tomotifs-scored.tsv.find-motifsandscore-motifsfollow the same output format, described in the table below:ColumnDescriptioncontigcontig in which the motif was foundmotifsequence of the detected motif in IUPAC formatmod_positionposition within the motif where the methylation is located. 0-based index.mod_typethe type of modification [a (6mA) or m (5mC)]n_modnumber of motif positions that are methylated in the contign_nomodnumber of motif positions that are not methylated in the contigmotifs_typetype of motif the sequence (palindrome, non-palindrome, bipartite or ambiguous)motif_complementSequence of the complement motif if present in IUPAC format.mod_position_complementPosition within the complement motif where the methylation is located. 0-based index.n_mod_complementNumber of motif positions that are methylated in the contig.n_nomod_complementNumber of motif positions that are not methylated in the contig.Runningfind-motifsgenerates pre-cleanup folder, which contains motif that got removed in the postprocessing steps. The name of the file indicates which postprocessing steps have been run on the motifs.bin-consensusbin-consensusoutputs results tobin-motifs.tsvThe format is almost identical the the output of find-motifs, except everything is aggregated to bin level and the contig column is replaced by a bin columnColumnDescriptionbinbin to which the motif belongmotifsequence of the detected motif in IUPAC formatmod_positionposition within the motif where the methylation is located. 0-based index.mod_typethe type of modification [a (6mA) or m (5mC)]n_modnumber of motif positions that are methylated in all contigs in the binn_nomodnumber of motif positions that are not methylated in all contigs in the binmotifs_typetype of motif the sequence (palindrome, non-palindrome, bipartite or ambiguous)motif_complementSequence of the complement motif if present.mod_position_complementPosition within the complement motif where the methylation is located. 0-based index.n_mod_complementNumber of motif positions that are methylated in all contigs in the binn_nomod_complementNumber of motif positions that are not methylated in all contigs in the binLicenseNanomotif is released under theMIT License. Feel free to use, modify, and distribute the package in accordance with the terms of the license.AcknowledgmentsNanomotif builds upon various open-source libraries and tools that are instrumental in its functionality. We would like to express our gratitude to the developers and contributors of these projects for their valuable work.