<jupyter_start><jupyter_text>NanoCount python API  Activate virtual environment<jupyter_code>from NanoCount.NanoCount import NanoCount
from NanoCount.common import jhelp, head<jupyter_output><empty_output><jupyter_text>Running NanoCount<jupyter_code>jhelp(NanoCount)<jupyter_output><empty_output><jupyter_text>Basic command<jupyter_code>NanoCount (alignment_file="./data/aligned_reads_sorted.bam", count_file="./output/tx_counts.tsv")
head("./output/tx_counts.tsv")<jupyter_output>[01;34m## Checking options and input files ##[0m
[01;34m## Initialise Nanocount ##[0m
[32m	Parse Bam file and filter low quality alignments[0m
[32m	Summary of alignments parsed in input bam file[0m
[32m		Valid alignments: 150,517[0m
[32m		Discarded unmapped alignments: 9,545[0m
[32m		Discarded alignment with invalid 3 prime end: 6,133[0m
[32m		Discarded negative strand alignments: 4,515[0m
[32m		Discarded supplementary alignments: 334[0m
[32m	Summary of reads filtered[0m
[32m		Reads with valid best alignment: 85,908[0m
[32m		Invalid secondary alignments: 60,120[0m
[32m		Valid secondary alignments: 2,622[0m
[32m		Reads with low query fraction aligned: 1,628[0m
[32m	Generate initial read/transcript compatibility index[0m
[01;34m## Start EM abundance estimate ##[0m
	Progress: 2.00 rounds [00:00, 7.55 rounds/s]
[32m	Exit EM loop after 2 rounds[0m
[32m	Convergence value: 0.0019361726963877538[0m
[01;34m## Summarize data ##[0m
[32m	Convert results to da[...]<jupyter_text>Using Best Alignment score rather than Primary reads as best reads<jupyter_code>NanoCount (alignment_file="./data/aligned_reads_sorted.bam", count_file="./output/tx_counts.tsv", primary_score="align_score")
head("./output/tx_counts.tsv")<jupyter_output>[01;34m## Checking options and input files ##[0m
[01;34m## Initialise Nanocount ##[0m
[32m	Parse Bam file and filter low quality alignments[0m
[32m	Summary of alignments parsed in input bam file[0m
[32m		Valid alignments: 150,517[0m
[32m		Discarded unmapped alignments: 9,545[0m
[32m		Discarded alignment with invalid 3 prime end: 6,133[0m
[32m		Discarded negative strand alignments: 4,515[0m
[32m		Discarded supplementary alignments: 334[0m
[32m	Summary of reads filtered[0m
[32m		Reads with valid best alignment: 85,805[0m
[32m		Valid secondary alignments: 54,985[0m
[32m		Invalid secondary alignments: 7,651[0m
[32m		Reads with low query fraction aligned: 1,731[0m
[32m	Generate initial read/transcript compatibility index[0m
[01;34m## Start EM abundance estimate ##[0m
	Progress: 37.0 rounds [00:05, 6.40 rounds/s]
[32m	Exit EM loop after 37 rounds[0m
[32m	Convergence value: 0.004936880753967912[0m
[01;34m## Summarize data ##[0m
[32m	Convert results to da[...]<jupyter_text>Write selected alignment to BAM file<jupyter_code>NanoCount (
    alignment_file="./data/aligned_reads_sorted.bam",
    count_file="./output/tx_counts.tsv",
    filter_bam_out = "./output/aligned_reads_selected.bam",
    primary_score="align_score")

head("./output/tx_counts.tsv")<jupyter_output>[01;34m## Checking options and input files ##[0m
[01;34m## Initialise Nanocount ##[0m
[32m	Parse Bam file and filter low quality alignments[0m
[32m	Summary of alignments parsed in input bam file[0m
[32m		Valid alignments: 150,517[0m
[32m		Discarded unmapped alignments: 9,545[0m
[32m		Discarded alignment with invalid 3 prime end: 6,133[0m
[32m		Discarded negative strand alignments: 4,515[0m
[32m		Discarded supplementary alignments: 334[0m
[32m	Summary of reads filtered[0m
[32m		Reads with valid best alignment: 85,805[0m
[32m		Valid secondary alignments: 54,985[0m
[32m		Invalid secondary alignments: 7,651[0m
[32m		Reads with low query fraction aligned: 1,731[0m
[32m	Write selected alignments to BAM file[0m
[32m	Summary of alignments written to bam[0m
[32m		Alignments to select: 140,790[0m
[32m		Alignments written: 140,790[0m
[32m		Alignments skipped: 30,254[0m
[32m	Generate initial read/transcript compatibility index[0m
[01;34m## Start EM abundanc[...]<jupyter_text>Basic command without file writing and Dataframe output In interactive mode it is also possible not to write the results out but instead to access the data directly as a pandas DataFrame<jupyter_code>nc = NanoCount (alignment_file="./data/aligned_reads_sorted.bam")
display(nc.count_df)<jupyter_output>[01;34m## Checking options and input files ##[0m
[01;34m## Initialise Nanocount ##[0m
[32m	Parse Bam file and filter low quality alignments[0m
[32m	Summary of alignments parsed in input bam file[0m
[32m		Valid alignments: 150,517[0m
[32m		Discarded unmapped alignments: 9,545[0m
[32m		Discarded alignment with invalid 3 prime end: 6,133[0m
[32m		Discarded negative strand alignments: 4,515[0m
[32m		Discarded supplementary alignments: 334[0m
[32m	Summary of reads filtered[0m
[32m		Reads with valid best alignment: 85,908[0m
[32m		Invalid secondary alignments: 60,120[0m
[32m		Valid secondary alignments: 2,622[0m
[32m		Reads with low query fraction aligned: 1,628[0m
[32m	Generate initial read/transcript compatibility index[0m
[01;34m## Start EM abundance estimate ##[0m
	Progress: 2.00 rounds [00:00, 8.28 rounds/s]
[32m	Exit EM loop after 2 rounds[0m
[32m	Convergence value: 0.0019361726963877538[0m
[01;34m## Summarize data ##[0m
[32m	Convert results to da[...]<jupyter_text>Adding extra transcripts information The `extra_tx_info` option adds a columns with the transcript lengths and also includes all the zero-coverage transcripts in the results<jupyter_code>nc = NanoCount (alignment_file="./data/aligned_reads_sorted.bam", extra_tx_info=True)
display(nc.count_df)<jupyter_output>[01;34m## Checking options and input files ##[0m
[01;34m## Initialise Nanocount ##[0m
[32m	Parse Bam file and filter low quality alignments[0m
[32m	Summary of alignments parsed in input bam file[0m
[32m		Valid alignments: 150,517[0m
[32m		Discarded unmapped alignments: 9,545[0m
[32m		Discarded alignment with invalid 3 prime end: 6,133[0m
[32m		Discarded negative strand alignments: 4,515[0m
[32m		Discarded supplementary alignments: 334[0m
[32m	Summary of reads filtered[0m
[32m		Reads with valid best alignment: 85,908[0m
[32m		Invalid secondary alignments: 60,120[0m
[32m		Valid secondary alignments: 2,622[0m
[32m		Reads with low query fraction aligned: 1,628[0m
[32m	Generate initial read/transcript compatibility index[0m
[01;34m## Start EM abundance estimate ##[0m
	Progress: 2.00 rounds [00:00, 7.69 rounds/s]
[32m	Exit EM loop after 2 rounds[0m
[32m	Convergence value: 0.0019361726963877538[0m
[01;34m## Summarize data ##[0m
[32m	Convert results to da[...]<jupyter_text>Relaxing the secondary alignment scoring threshold The default value is 0.95 (95% of the alignment score of the primary alignment) but this value could be lowered to allow more secondary alignments to be included in the uncertainty calculation.Lowering the value bellow 0.75 might not be relevant and will considerably increase the computation time.<jupyter_code>NanoCount (alignment_file="./data/aligned_reads_sorted.bam", count_file="./output/tx_counts.tsv", sec_scoring_threshold=0.8, extra_tx_info=True)
head("./output/tx_counts.tsv")<jupyter_output>[01;34m## Checking options and input files ##[0m
[01;34m## Initialise Nanocount ##[0m
[32m	Parse Bam file and filter low quality alignments[0m
[32m	Summary of alignments parsed in input bam file[0m
[32m		Valid alignments: 150,517[0m
[32m		Discarded unmapped alignments: 9,545[0m
[32m		Discarded alignment with invalid 3 prime end: 6,133[0m
[32m		Discarded negative strand alignments: 4,515[0m
[32m		Discarded supplementary alignments: 334[0m
[32m	Summary of reads filtered[0m
[32m		Reads with valid best alignment: 85,908[0m
[32m		Valid secondary alignments: 49,092[0m
[32m		Invalid secondary alignments: 13,650[0m
[32m		Reads with low query fraction aligned: 1,628[0m
[32m	Generate initial read/transcript compatibility index[0m
[01;34m## Start EM abundance estimate ##[0m
	Progress: 17.0 rounds [00:02, 6.81 rounds/s]
[32m	Exit EM loop after 17 rounds[0m
[32m	Convergence value: 0.004795139982321842[0m
[01;34m## Summarize data ##[0m
[32m	Convert results to d[...]
{'fraction_non_alphanumeric': 0.12017839922854388, 'fraction_numerical': 0.09956605593056896, 'mean_word_length': 6.481514878268711, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '601400', 'license': 'MIT', 'n_tokens_mistral': 3635, 'n_tokens_neox': 2823, 'n_words': 774, 'path': 'docs/NanoCount_API_usage.ipynb', 'repo_name': 'a-slide/nano_count', 'size': '8296'}