Giter VIP home page Giter VIP logo

methplotlib's People

Contributors

endrebak avatar wdecoster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

methplotlib's Issues

calls file not recognised

Hi, I've been using methplotlib for representing my methylation frequencies. However I am having problems for representing the calls. The file is in the nanopolish call format and does not seem to have any problems when I check it (I tried with more than one calls file)

$ methplotlib -m /data/cephfs/punim1048/allbarcoded/CORT/CORT13/methylation_chromosomes/chr10_methylation_calls.tsv -n CORT13 -w ch10:63273264-63314576 -g /data/cephfs/punim1048/GRCm38_genome/annotation/mm10.ensGene.gtf --simplify

Input file /data/cephfs/punim1048/allbarcoded/CORT/CORT13/methylation_chromosomes/chr10_methylation_calls.tsv not recognized!

Detailed error:
Traceback (most recent call last):
File "/home/coracollar/anaconda3/envs/methplot/bin/methplotlib", line 10, in
sys.exit(main())
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/methplotlib.py", line 18, in main
meth_data = get_data(args.methylation, args.names, window, args.smooth)
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/import_methylation.py", line 165, in get_data
return [read_meth(f, n, window, smoothen) for f, n in zip(methylation_files, names)]
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/import_methylation.py", line 165, in
return [read_meth(f, n, window, smoothen) for f, n in zip(methylation_files, names)]
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/import_methylation.py", line 32, in read_meth
return parse_nanopolish(filename, file_type, name, window, smoothen=smoothen)
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/import_methylation.py", line 51, in parse_nanopolish
gr.pos = np.floor(gr.drop().df[["Start", "End"]].mean(axis=1))
File "/home/coracollar/.local/lib/python3.7/site-packages/pandas/core/frame.py", line 2806, in getitem
indexer = self.loc._get_listlike_indexer(key, axis=1, raise_missing=True)[1]
File "/home/coracollar/.local/lib/python3.7/site-packages/pandas/core/indexing.py", line 1552, in _get_listlike_indexer
keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
File "/home/coracollar/.local/lib/python3.7/site-packages/pandas/core/indexing.py", line 1639, in _validate_read_indexer
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['Start', 'End'], dtype='object')] are in the [columns]"

What kind of analysis to use in differential_modification.py for multiway analysis?

By the way, allele_specific_modification.py does something very similar to differential_modification.py, only focussing on a simpler case of a 1 vs 1 comparison. The same improvements can probably be made in both scripts. The differential_modification script would eventually need better stats handling when comparing groups of samples, but for now I've just implemented this as a simple fisher exact test, which does suffice for within sample allele_specific_modification but is not optimal for across multiple samples differential_modification...

What kind of differential analysis did you have in mind for a multiway comparison?

Enabling output from methylation aware guppy

It would be nice if we can add input from methylation aware basecalling from the recent guppy versions. Unfortunately, they put their methylation information in the fast5 file and not some easily parseable tabular data. One of these is available at: https://drive.google.com/file/d/1H4xiOw9Q4bbTBbunlJX2Be1YbPoQC_qh/view?usp=sharing

But I would probably prefer to use the cram format, from https://github.com/EGA-archive/ont2cram
However, I come across an issue when trying ont2cram on the fast5 mentioned above, reported at EGA-archive/ont2cram#19

Also, we have to think about how to first align this with a reference genome, as the methylation is now just per-read and doesn't have a genomic position assigned - yet.
Maybe that too is something where the cram format can make our lives easier if we can align that... and keep the methylation information properly synced.

Bug?

I'm trying to run methplotlib with the following command:

methplotlib -m mod_mappings.sorted.bam -n Run10 -w tig00000001 -f ../Run10_contigs.fasta -o Run10.out 2> Run10.log

and I get the following error:

2021-06-30 18:27:57,790 methplotlib 0.19.0 started.
2021-06-30 18:27:57,790 Python version is: 3.6.13 | packaged by conda-forge | (default, Feb 19 2021, 05:36:01) [GCC 9.3.0]
2021-06-30 18:27:57,790 Arguments are: Namespace(bed=None, binary=False, dotsize=4, example=False, fasta='../Run10_contigs.fasta', gtf=None, methylation=['mod_mappings.sorted.bam'], minqual=20, names=['Run10'], outfile='Run10.out', qcfile=None, simplify=False, smooth=5, split=False, static=None, store=False, window='tig00000001')
2021-06-30 18:27:57,791 Processing tig00000001_0_965899
2021-06-30 18:27:57,792 File mod_mappings.sorted.bam is of type bam
2021-06-30 18:28:10,057 Error processing mod_mappings.sorted.bam.
2021-06-30 18:28:10,057 local variable 'refpos' referenced before assignment
Traceback (most recent call last):
File "/home/torben/opt/anaconda3/envs/megalodon/lib/python3.6/site-packages/methplotlib/import_methylation.py", line 54, in read_mods
return parse_cram(filename, file_type, name, window)
File "/home/torben/opt/anaconda3/envs/megalodon/lib/python3.6/site-packages/methplotlib/import_methylation.py", line 213, in parse_cram
mod_positions = get_modified_reference_positions(read)
File "/home/torben/opt/anaconda3/envs/megalodon/lib/python3.6/site-packages/methplotlib/import_methylation.py", line 278, in get_modified_reference_positions
refpos[modified_bases], # pos
UnboundLocalError: local variable 'refpos' referenced before assignment

Any thoughts on what is causing it? I am using Megalodon to generate the BAM file.

No records for file in in 15_25576970_25685978!

After some work I managed to use the github repo to get the right methplotlib version.

However my bedmethylfile looks like this:

15 25685968 25685969 h 12 + 25685968 25685969 255,0,0 12 0.00 0 0 12 0 2 1 0
15 25685968 25685969 m 12 + 25685968 25685969 255,0,0 12 100.00 12 0 0 0 2 1 0
15 25685969 25685970 h 12 - 25685969 25685970 255,0,0 12 8.33 1 0 11 0 1 0 1
15 25685969 25685970 m 12 - 25685969 25685970 255,0,0 12 91.67 11 0 1 0 1 0 1
15 25685976 25685977 h 14 + 25685976 25685977 255,0,0 14 0.00 0 0 14 0 1 0 0
15 25685976 25685977 m 14 + 25685976 25685977 255,0,0 14 100.00 14 0 0 0 1 0 0
15 25685977 25685978 h 14 - 25685977 25685978 255,0,0 14 0.00 0 1 13 0 0 0 0
15 25685977 25685978 m 14 - 25685977 25685978 255,0,0 14 92.86 13 1 0 0 0 0 0

I get an error saying there are no records, while clearly there are.

Also when I try another region, region X, of the same file, it works perfectly fine.

How to fix?

I use pod5 data, modbasecall it with dorado, next is modkit with function --only-tabs and then the methplotlib. So i have no influence on the names of first collumn

different version different error

Hi @wdecoster,

Firstly, thank you for providing this program. I am currently working on one of nanopolish results and ı have a methylation call and frequency .tsv file. The methplotlib version 0.8 works fine on that input and generates graphs, however, a newer version of methplotlib like 0.17 and 0.20 gives an error. I have the same environment for them but get different errors. Many thanks.

2022-04-19 10:20:56,900 methplotlib 0.17.0 started.
2022-04-19 10:20:56,901 Python version is: 3.9.12 (main, Apr 5 2022, 06:56:58) [GCC 7.5.0]
2022-04-19 10:20:56,901 Arguments are: Namespace(methylation=['61fast28x2_methylation_calls.tsv', '61fast28x2_methylation_frequency.tsv'], names=['calls', '61fast28x2testmethplotlib17'], window='16:10,980,759-11,045,000', gtf='GRCh38_latest_genomic.gff.gz', bed='61fast28x2.sorted.bed', fasta=None, simplify=True, split=False, static=None, binary=False, smooth=5, dotsize=4, example=False, outfile=None, qcfile=None, store=False)
2022-04-19 10:20:56,901 Processing 16_10980759_11045000
2022-04-19 10:20:56,937 File 61fast28x2_methylation_calls.tsv is of type nanopolish_call
2022-04-19 10:20:56,937 Reading 61fast28x2_methylation_calls.tsv slowly by splitting the file in chunks.
2022-04-19 10:23:11,798 Read the file in a dataframe.
2022-04-19 10:23:11,825 Error processing 61fast28x2_methylation_calls.tsv.
2022-04-19 10:23:11,825 "None of [Index(['Start', 'End'], dtype='object')] are in the [columns]"
Traceback (most recent call last):
File "/cluster/lrcfs/ftiras/ftiras_env/envs/R/lib/python3.9/site-packages/methplotlib/import_methylation.py", line 47, in read_meth
return parse_nanopolish(filename, file_type, name, window, smoothen=smoothen)
File "/cluster/lrcfs/ftiras/ftiras_env/envs/R/lib/python3.9/site-packages/methplotlib/import_methylation.py", line 101, in parse_nanopolish
gr.pos = np.floor(gr.drop().df[["Start", "End"]].mean(axis=1))
File "/cluster/lrcfs/ftiras/ftiras_env/envs/R/lib/python3.9/site-packages/pandas/core/frame.py", line 3511, in getitem
indexer = self.columns._get_indexer_strict(key, "columns")[1]
File "/cluster/lrcfs/ftiras/ftiras_env/envs/R/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 5782, in _get_indexer_strict
self._raise_if_missing(keyarr, indexer, axis_name)
File "/cluster/lrcfs/ftiras/ftiras_env/envs/R/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 5842, in _raise_if_missing
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['Start', 'End'], dtype='object')] are in the [columns]"

and error for version 0.20
Reading 61fast28x2_methylation_calls.tsv would be faster with bgzip and tabix.
Please index with 'tabix -S1 -s1 -b3 -e4'.
/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/lib/python3.7/site-packages/methplotlib/import_methylation.py:50: DtypeWarning: Columns (0) have mixed types.Specify dtype option on import or set low_memory=False.
return parse_nanopolish(filename, file_type, name, window, smoothen=smoothen)

Reading 61fast28x2_methylation_frequency.tsv would be faster with bgzip and tabix.
Please index with 'tabix -S1 -s1 -b2 -e3'.
/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/lib/python3.7/site-packages/methplotlib/annotation.py:146: DtypeWarning:

Columns (0) have mixed types.Specify dtype option on import or set low_memory=False.

Traceback (most recent call last):
File "/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/bin/methplotlib", line 10, in
sys.exit(main())
File "/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/lib/python3.7/site-packages/methplotlib/methplotlib.py", line 36, in main
minqual=args.minqual, # only for input in bam/cram format
File "/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/lib/python3.7/site-packages/methplotlib/methplotlib.py", line 107, in meth_browser
annotation_traces, y_max = plots.gtf_annotation(gtf, window, simplify)
File "/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/lib/python3.7/site-packages/methplotlib/plots.py", line 38, in gtf_annotation
annotation = parse_annotation(gtf, window, simplify)
File "/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/lib/python3.7/site-packages/methplotlib/annotation.py", line 92, in parse_annotation
for line in open_gtf(gtff) if good_record(line, window.chromosome)],
File "/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/lib/python3.7/site-packages/methplotlib/annotation.py", line 92, in
for line in open_gtf(gtff) if good_record(line, window.chromosome)],
File "/cluster/lrcfs/ftiras/ftiras_env/envs/Methplotlib17/lib/python3.7/site-packages/methplotlib/annotation.py", line 35, in good_record
if line.startswith(chromosome)
TypeError: startswith first arg must be str or a tuple of str, not int

Pandas.error and shape mismatch

Dear Wouter,
I am getting the following error. The version of methplotlib I am using is 0.13.1. Please help.

methplotlib -m methylation_calls_CpG_sm1.tsv.gz methylation_frequency_sm1.tsv.gz -n calls frequencies -w mtDNA:1-16,626 -g /cluster/projects/nn9337k/as1_nanopolish/all_context/sequence.sorted.gtf.gz --simplify -b /cluster/projects/nn9337k/as1/reference.bed -f /cluster/projects/nn9337k/as1/reference.fasta

Traceback (most recent call last):
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3621, in get_loc
return self._engine.get_loc(casted_key)
File "pandas/_libs/index.pyx", line 136, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 142, in pandas._libs.index.IndexEngine.get_loc
TypeError: '18910 False
18973 False
19035 False
19097 False
19159 False
...
22925 False
23000 True
23074 False
23148 False
23224 False
Name: log_lik_ratio, Length: 28154, dtype: bool' is an invalid key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/series.py", line 1085, in setitem
self._set_with_engine(key, value)
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/series.py", line 1146, in _set_with_engine
loc = self.index.get_loc(key)
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3628, in get_loc
self._check_indexing_error(key)
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 5637, in _check_indexing_error
raise InvalidIndexError(key)
pandas.errors.InvalidIndexError: 18910 False
18973 False
19035 False
19097 False
19159 False
...
22925 False
23000 True
23074 False
23148 False
23224 False
Name: log_lik_ratio, Length: 28154, dtype: bool

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/bin/methplotlib", line 8, in
sys.exit(main())
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/methplotlib/methplotlib.py", line 27, in main
meth_browser(meth_data=meth_data,
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/methplotlib/methplotlib.py", line 51, in meth_browser
meth_traces = plots.methylation(meth_data, dotsize=dotsize)
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/methplotlib/plots.py", line 105, in methylation
make_per_read_meth_traces_llr(table=meth.table,
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/methplotlib/plots.py", line 167, in make_per_read_meth_traces_llr
table.loc[:, "llr_scaled"] = rescale_log_likelihood_ratio(table["log_lik_ratio"].copy())
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/methplotlib/plots.py", line 253, in rescale_log_likelihood_ratio
llr[llr > 0] = scaler.fit_transform(llr[llr > 0].values.reshape(-1, 1)).tolist()
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/series.py", line 1127, in setitem
self._set_values(indexer, value)
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/series.py", line 1185, in _set_values
self._mgr = self._mgr.setitem(indexer=key, value=value)
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/internals/managers.py", line 337, in setitem
return self.apply("setitem", indexer=indexer, value=value)
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/internals/managers.py", line 304, in apply
applied = getattr(b, f)(**kwargs)
File "/cluster/projects/nn9337k/anaconda/envs/methplotlib/lib/python3.10/site-packages/pandas/core/internals/blocks.py", line 959, in setitem
values[indexer] = value
ValueError: shape mismatch: value array of shape (5284,1) could not be broadcast to indexing result of shape (5284,)

sbatch example of methplotlib

Hello,

I will like to run methplotlib on a cluster and I was wonder if you have an example of a sbatch script to run of the cluster.
As I did not installed the software I am wondering which modules I need to load in order to run the script provided here.
Best,

Tania

Found 0 gene(s) in the region.

I have a gff3 file that I downloaded from the Microscope Annotation platform. This is how the file looks:

##gff-version 3
##sequence-region TQC00001.1 1 2035761
TQC00010.1	annotation	remark	1	2035761	.	.	.	accession=TQC00001.1;comment=Annotations were generated from the MicroScope annotation platform. Additional results are available at http://www.genoscope.cns.fr/agc/microscope . This file is not suitable for direct databank submission. To contact us: mage%40genoscope.cns.fr .%0AMicroscope genomic region coordinates: 1..2035761;data_file_division=BCT;date=25-NOV-2019;organism=Genus Species;source=Genus Species;topology=linear
TQC00010.1	feature	region	1	2035761	.	+	.	Is_circular=false;Note=whole genome shotgun linear WGS contig 1;db_xref=taxon:1907535,MaGe/Organism_id:12250,MaGe/Species_code:TQUA2019,MaGe/Sequence_id:16851,MaGe/Scaffold_id:1,MaGe/Contig_id:1,MaGe/Contig_label:scaffold1;mol_type=genomic DNA;organism=Candidatus Thiosymbion quadrati;strain=ONT2019
TQC00010.1	feature	gene	168	2300	.	+	.	locus_tag=TQUA2019_v1_10001
TQC00010.1	feature	CDS	168	2300	.	+	0	ID=71761160;db_xref=MaGe:71761160;inference=ab initio prediction:AMIGene:2.0;locus_tag=TQUA2019_v1_10001;product=N-6 DNA methylase;transl_table=11;translation=M
TQC00010.1	feature	gene	2300	3358	.	+	.	locus_tag=TQUA2019_v1_10002
TQC00010.1	feature	CDS	2300	3358	.	+	0	ID=71761161;db_xref=MaGe:71761161;inference=ab initio prediction:AMIGene:2.0;locus_tag=TQUA2019_v1_10002;product=2-hydroxyacid dehydrogenase;transl_table=11;translation=M
TQC00010.1	feature	gene	3529	4179	.	+	.	locus_tag=TQUA2019_v1_10003
TQC00010.1	feature	CDS	3529	4179	.	+	0	ID=71761162;db_xref=MaGe:71761162;inference=ab initio prediction:AMIGene:2.0;locus_tag=TQUA2019_v1_10003;note=Evidence 5 : Unknown function;product=protein of unknown function;transl_table=11;translation=M

This is the log file:

2019-12-13 12:38:14,529 methplotlib 0.8.0 started.
Python version is: 3.7.0 (default, Sep  6 2018, 14:24:05)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Arguments are: Namespace(bed=None, example=False, gtf='file.gff', methylation=['methylation_calls_dam.mod.tsv.gz', 'methylation_calls_dam.mod.tsv.gz.freq.mod'], names=['calls', 'frequencies'], simplify=True, smooth=5, split=False, window='TQC00010.1:1-10000')
2019-12-13 12:38:14,530 Processing TQC00010.1_1_10000
2019-12-13 12:38:21,836 Read the file in a dataframe.
2019-12-13 12:38:21,900 File contains raw data.
2019-12-13 12:38:22,040 Read the file in a dataframe.
2019-12-13 12:38:22,057 File contains frequency data.
2019-12-13 12:38:22,065 Collected methylation data for 2 datasets
2019-12-13 12:38:24,886 Created QC plots
2019-12-13 12:38:28,085 Prepared methylation traces.
2019-12-13 12:38:31,383 Prepared modification plots.
2019-12-13 12:38:31,403 Parsing GTF file...
2019-12-13 12:38:31,451 Loaded GTF file, processing...
2019-12-13 12:38:31,456 Found 0 gene(s) in the region.

2019-12-13 12:38:31,465 Prepared annotation plots.
2019-12-13 12:38:34,397 Finished!

The plotting works, but as said, there are no annotations plotted. What is wrong with my gff-file?

bgzip, tabix and sorting

Hi @wdecoster

I have 2 nanopolish output tsv files (calls and frequencies). I would like to use them as input for methplotlib. I have tried to sort as you wrote in an example but when i want to use tabix it gives an unsorted error.

cat <(head -n1 sample8_methylation_calls_2.tsv) <(tail -n +2 sample8_methylation_calls_2.tsv | sort -k2,2 -k3,3) | bgzip > sample8_sort_calls.tsv.gz

tabix -S1 -s1 -b3 -e4 sample8_methylation_calls_2.tsv.gz

Looking at the sorted and decompressed tsv file i see that the problem is between the plus and minus strand:
image

Should it only be sorted by the 3 column and how can this be done?

No calls in window

Dear,

The tool worked great for me, but for one sample it is not working. This is what I get:
`methplotlib -m meth_calls2_LILBR1.tsv meth_freqs2_LILRB1.tsv -n Calls Frequencies -w "19:5440600-54424828" -o lilrb1.html

Reading meth_calls2_LILBR1.tsv would be faster with bgzip and tabix.
Please index with 'tabix -S1 -s1 -b3 -e4'.
/home/algemeen/anaconda3/lib/python3.7/site-packages/pandas/core/ops.py:1649: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
result = method(y)

Problem parsing nanopolish file meth_calls2_LILBR1.tsv!
Could it be that there are no calls in your selected window?

Detailed error:

Error processing meth_calls2_LILBR1.tsv!

Detailed error:
Traceback (most recent call last):
File "/home/algemeen/anaconda3/bin/methplotlib", line 10, in
sys.exit(main())
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/methplotlib/methplotlib.py", line 17, in main
meth_data = get_data(args.methylation, args.names, window, args.smooth)
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/methplotlib/import_methylation.py", line 30, in get_data
return [read_meth(f, n, window, smoothen) for f, n in zip(methylation_files, names)]
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/methplotlib/import_methylation.py", line 30, in
return [read_meth(f, n, window, smoothen) for f, n in zip(methylation_files, names)]
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/methplotlib/import_methylation.py", line 47, in read_meth
return parse_nanopolish(filename, file_type, name, window, smoothen=smoothen)
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/methplotlib/import_methylation.py", line 101, in parse_nanopolish
gr.pos = np.floor(gr.drop().df[["Start", "End"]].mean(axis=1))
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py", line 2934, in getitem
raise_missing=True)
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/pandas/core/indexing.py", line 1354, in _convert_to_indexer
return self._get_listlike_indexer(obj, axis, **kwargs)[1]
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/pandas/core/indexing.py", line 1161, in _get_listlike_indexer
raise_missing=raise_missing)
File "/home/algemeen/anaconda3/lib/python3.7/site-packages/pandas/core/indexing.py", line 1246, in _validate_read_indexer
key=key, axis=self.obj._get_axis_name(axis)))
KeyError: "None of [Index(['Start', 'End'], dtype='object')] are in the [columns]"`

It says there are no calls in the selected window, but when I check my called tsk file, there are calls in the window: see attachment for a sample.

calls.txt

What could go wrong here?

Bacterial genomes.

I am working with bacterial genomes so they do not have chromosome numbering as you will see with a human genome . How will you input the window in this setting errors. ( e.g 1000-5000 not in cdiffstr22457.fasta )

problems in methplotlib 0.13.0

Hi, I have installed methplotlib and tried the example and works.
Now I have tried the simplest command with my data:
$ methplotlib -m chr10_methylation_calls.tsv chr10_methylation_frequency_chr10.tsv -n calls frequencies -w chr10:5,525,542-5,543,028

And obtained the following error

Traceback (most recent call last):
File "/home/coracollar/.local/lib/python3.7/site-packages/pandas/core/series.py", line 1014, in setitem
self._set_with_engine(key, value)
File "/home/coracollar/.local/lib/python3.7/site-packages/pandas/core/series.py", line 1054, in _set_with_engine
self.index._engine.set_value(values, key, value)
File "pandas/_libs/index.pyx", line 96, in pandas._libs.index.IndexEngine.set_value
File "pandas/_libs/index.pyx", line 106, in pandas._libs.index.IndexEngine.set_value
File "pandas/_libs/index.pyx", line 116, in pandas._libs.index.IndexEngine.get_loc
TypeError: '605 True
621 True
637 False
653 True
668 True
...
1597 True
1615 True
1633 True
1651 True
1669 True
Name: log_lik_ratio, Length: 1685, dtype: bool' is an invalid key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/coracollar/anaconda3/envs/methplot/bin/methplotlib", line 10, in
sys.exit(main())
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/methplotlib.py", line 34, in main
dotsize=args.dotsize
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/methplotlib.py", line 51, in meth_browser
meth_traces = plots.methylation(meth_data, dotsize=dotsize)
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/plots.py", line 107, in methylation
dotsize=dotsize)
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/plots.py", line 167, in make_per_read_meth_traces_llr
table.loc[:, "llr_scaled"] = rescale_log_likelihood_ratio(table["log_lik_ratio"].copy())
File "/home/coracollar/anaconda3/envs/methplot/lib/python3.7/site-packages/methplotlib/plots.py", line 253, in rescale_log_likelihood_ratio
llr[llr > 0] = scaler.fit_transform(llr[llr > 0].values.reshape(-1, 1))
File "/home/coracollar/.local/lib/python3.7/site-packages/pandas/core/series.py", line 1037, in setitem
self._where(~key, value, inplace=True)
File "/home/coracollar/.local/lib/python3.7/site-packages/pandas/core/generic.py", line 8727, in _where
new_other[icond] = other
TypeError: NumPy boolean array indexing assignment requires a 0 or 1-dimensional input, input has 2 dimensions

AttributeError: module 'plotly' has no attribute 'subplots'

Hi, sorry to keep bugging you. I had the below error today.

methplotlib -m guppy_out/sample0.bam -w CM025008.1:1-146 -n sample0 -f resources/Masked_Genome_061021.fa
Traceback (most recent call last):
File "/home/matthew/anaconda3/envs/methplotlib/bin/methplotlib", line 10, in
sys.exit(main())
File "/home/matthew/anaconda3/envs/methplotlib/lib/python3.9/site-packages/methplotlib/methplotlib.py", line 26, in main
meth_browser(meth_data=meth_data,
File "/home/matthew/anaconda3/envs/methplotlib/lib/python3.9/site-packages/methplotlib/methplotlib.py", line 89, in meth_browser
fig = utils.create_subplots(num_methrows, split=False, annotation=bool(bed or gtf))
File "/home/matthew/anaconda3/envs/methplotlib/lib/python3.9/site-packages/methplotlib/utils.py", line 261, in create_subplots
return plotly.subplots.make_subplots(
File "/home/matthew/anaconda3/envs/methplotlib/lib/python3.9/site-packages/_plotly_utils/importers.py", line 39, in getattr
raise AttributeError(
AttributeError: module 'plotly' has no attribute 'subplots'

Now according to the issue here:

plotly/plotly.py#2443

The plotly team changed how to import subplots from plotly, at least that is my interpretation. Not sure which release changed it, sometime between 4.7.1 and 5.5.

It sounds like if you add:

from plotly import subplots
from plotly.subplots import make_subplots

into utils.py, then it should work again.

I went ahead and tried adding it to my utils.py and that seems to have gotten rid of the error.

cannot import name 'get_all_ties'

Hi @wdecoster

I get an error about get_all_ties that i do not know how to fix.

(methplotlib_caroline_python3) root@srvodeappgsq02:/home/martin# methplotlib -h
Traceback (most recent call last):
File "/root/miniconda3/envs/methplotlib_caroline_python3/bin/methplotlib", line 5, in
from methplotlib.methplotlib import main
File "/root/miniconda3/envs/methplotlib_caroline_python3/lib/python3.10/site-packages/methplotlib/methplotlib.py", line 1, in
import methplotlib.plots as plots
File "/root/miniconda3/envs/methplotlib_caroline_python3/lib/python3.10/site-packages/methplotlib/plots.py", line 2, in
from methplotlib.annotation import parse_annotation, parse_bed
File "/root/miniconda3/envs/methplotlib_caroline_python3/lib/python3.10/site-packages/methplotlib/annotation.py", line 2, in
import pyranges as pr
File "/root/miniconda3/envs/methplotlib_caroline_python3/lib/python3.10/site-packages/pyranges/init.py", line 137, in
import pyranges.genomicfeatures as gf
File "/root/miniconda3/envs/methplotlib_caroline_python3/lib/python3.10/site-packages/pyranges/genomicfeatures.py", line 7, in
from sorted_nearest.src.introns import find_introns
File "/root/miniconda3/envs/methplotlib_caroline_python3/lib/python3.10/site-packages/sorted_nearest/init.py", line 7, in
from sorted_nearest.src.k_nearest_ties import get_all_ties, get_different_ties
ImportError: cannot import name 'get_all_ties' from 'sorted_nearest.src.k_nearest_ties' (/root/miniconda3/envs/methplotlib_caroline_python3/lib/python3.10/site-packages/sorted_nearest/src/k_nearest_ties.cpython-310-x86_64-linux-gnu.so)

Best Caroline

Remora .bam as a input

Hi @wdecoster ,

This is not for error/issue. I am just wondering whether can I use the remora .bam file (MM/ML tag) as input. Also, I could not see the bam input option in the help options. thanks .:)

Add testing with py.test?

I can show that my new PR creates the same results as your old code. But I would like to add more tests to the CI using py.test. Is that OK?

Window parameter cannot deal with complicated fasta headers

Hi everyone,

I'm trying to use methplotlib, and I've run into some issues.
I'm trying to use it to analyze some reads I called earlier.
Issue number #1) There is no reference for this. To get around this, I converted one of the read fastq files to fasta, and used this one as reference
Issue #2) Obviously the reads don't have nice names. If I use -w "37b7bed0-436a-4676-a61a-023255f80bee runid=0fa505d79c6c1b4fe0085a62e508181b26c78340 sampleid=I22-1145-01 read=168 ch=445 start_time=2022-05-19T13:59:55Z [email protected]:1-200"

I get ERROR: Window (-w/--window) inproperly formatted, examples of accepted formats are:
'chr5:150200605-150423790' or 'ENST00000647408'

I do understand the error, but in theory my input is proper, I guess. Just the fasta header is complicated.,

If you have any other advice how I could visualize my data, then I'd be very happy.

Thanks,
Bastian

Can bam files from guppy version v.6.1.1 be used?

Hi

I'm new in methylation data and have a bam file with the Mm and Ml tags for methylation, produced by the newest guppy version v.6.1.1

Can this be used as input to methplotlib? And how to deal with the -n names argument required when the methylation data is in the tags?

What kind of Nanocompore outputs should be used?

Dear Wouter,

I am interested in using Methplotlib for visualizing m6A RNA frequencies and probability output by nanocompore.

The Nanocompore SampComp function generated several files named "simulated_shift.tsv", "simulated_report.tsv" and so on. Which files should I provide as inputs for Methplotlib. Could you explain a little bit more details on how to use Methplotlib with nanocompore outputs? Thanks for your time.

Sincerely,
Wonyong

gtf fails

I am trying to run methplotlib with nanopolish results and a genome and gtf file like this:

methplotlib -m AlKewell.nanopolish.methylation_frequency.tsv -n AlKewell -w AlKewell_ctg_3:1-2245191 -g test.gtf

I extracted a tiny bit from the gtf file that sits within the window I gave to methplotlib:

AlKewell_ctg_3	GeneMark.hmm	exon	1910059	1910105	0	+	.	gene_id "278_g"; transcript_id "278_t";
AlKewell_ctg_3	GeneMark.hmm	start_codon	1910059	1910061	.	+	0	gene_id "278_g"; transcript_id "278_t"; count "1_1";
AlKewell_ctg_3	GeneMark.hmm	CDS	1910059	1910105	.	+	0	gene_id "278_g"; transcript_id "278_t"; cds_type "Initial"; count "1_2";

This is the error I get:

Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/bin/methplotlib", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/miniconda3/lib/python3.7/site-packages/methplotlib/methplotlib.py", line 35, in main
    binary=args.binary,   
  File "/home/ubuntu/miniconda3/lib/python3.7/site-packages/methplotlib/methplotlib.py", line 106, in meth_browser
    annotation_traces, y_max = plots.gtf_annotation(gtf, window, simplify)  
  File "/home/ubuntu/miniconda3/lib/python3.7/site-packages/methplotlib/plots.py", line 35, in gtf_annotation
    annotation = parse_annotation(gtf, window, simplify) 
  File "/home/ubuntu/miniconda3/lib/python3.7/site-packages/methplotlib/annotation.py", line 117, in parse_annotation
    gene=tr["gene"].tolist()[0],  
IndexError: list index out of range

If I use an extract from the gtf that is not within the window I get this:

AlKewell_ctg_16	GeneMark.hmm	exon	1340573	1340784	0	-	.	gene_id "1_g"; transcript_id "1_t";
AlKewell_ctg_16	GeneMark.hmm	stop_codon	1340573	1340575	.	-	0	gene_id "1_g"; transcript_id "1_t"; count "1_1";
AlKewell_ctg_16	GeneMark.hmm	CDS	1340573	1340784	.	-	2	gene_id "1_g"; transcript_id "1_t"; cds_type "Terminal"; count "2_2";

Found 0 transcript(s) in the region.

Is there something wrong with this gtf? It is straight out of genemark.

Cheers

Using Megalodon files as input

Hi again!

I was trying to use Methplotlib to see if I can plot my Megalodon data for 6mA and 5mC. Simply converting my sorted BAM output using samtools to CRAM format and using that as an input is giving me the following error:

$ methplotlib -m barcode1.cram -n barcode01 -w 7e24d142adc2427d_1 -f reference.fasta -o outtrial1 
Traceback (most recent call last):
  File "/usr/local/bin/methplotlib", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/methplotlib/methplotlib.py", line 35, in main
    binary=args.binary,
  File "/usr/local/lib/python3.7/dist-packages/methplotlib/methplotlib.py", line 52, in meth_browser
    meth_traces = plots.methylation(meth_data, dotsize=dotsize, binary=binary)
  File "/usr/local/lib/python3.7/dist-packages/methplotlib/plots.py", line 121, in methylation
    dotsize=dotsize)
  File "/usr/local/lib/python3.7/dist-packages/methplotlib/plots.py", line 148, in make_per_read_meth_traces_phred
    table = table.join(df_heights, on="read_name")
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py", line 8108, in join
    other, on=on, how=how, lsuffix=lsuffix, rsuffix=rsuffix, sort=sort
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py", line 8140, in _join_compat
    sort=sort,
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/reshape/merge.py", line 87, in merge
    validate=validate,
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/reshape/merge.py", line 672, in __init__
    self._maybe_coerce_merge_keys()
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/reshape/merge.py", line 1193, in _maybe_coerce_merge_keys
    raise ValueError(msg)
ValueError: You are trying to merge on object and float64 columns. If you wish to proceed you should use pd.concat

I am very new to data analysis and I am unsure if this error is due to some issue with my input files/command syntax or if Megalodon outputs are not compatible with Methplotlib.

sklearn deprecated

Hello

Trying to install methplotlib using pip, I got following error:

    The 'sklearn' PyPI package is deprecated, use 'scikit-learn'
    rather than 'sklearn' for pip commands.

See also https://pypi.org/project/sklearn/ (which mentions a workaround)

Kind regards
Stefan

all context methylation visualization

Hello,

I am using megalodon to identify methylations in the whole genome, not only in the CpG islands.
I was wondering if it is possible to use Methplotlib to visualise also those regions outside the CpG context with the megalodon outputs.
Do you think it is compatible?

Thank you,
Paula

Errors supporting bedgraph files

Using version 0.20.1 there are a few errors recognizing the bed graph format as output by Nanopore's mod kit tool.

utils.py checks for 4 columns but this file has 5.

Moreover, it seems like even when that is fixed the tool fails to find records for regions present. For example, running: methplotlib -m m_positive1.bedgraph m_positive2.bedgraph m_positive3.bedgraph -n freq1 freq2 freq3 -f 106_sub.fna -w contig_13235 with the following gives:

No records for methylation/barcode01/106_sub-bedgraph/m_positive.bedgraph in contig_13235!

Despite m_positive1.bedgraph being, and the config also being present at least once in the other two bed graph files:

contig_13235	74	75	0	1
contig_13235	116	117	0	1
contig_13235	122	123	0	1
contig_13235	135	136	1	1
contig_13235	4865	4866	0	1
contig_13235	4872	4873	0	1
contig_13235	4875	4876	0	1
contig_13235	4880	4881	0	1
contig_13235	4885	4886	0	1
contig_13235	4894	4895	0	1

and cat 106_sub.fna | grep contig_13235 returns >contig_13235. This is true for other configs as well.

I would try this with the latest version however it is not published to Conda or pip, and the local uninstall proved to be a headache.

Input file not recognized

Hello,

I was trying out methplotlib, and my input data was a bedgraph file generated by Modkit. However, i am getting an input file not recognized message. Do you have any idea how to fix this?

This was my command:
methplotlib -m ./h_CG0_positive.bedgraph -n 20231004_1422_X2_FAW14788_8e4bf9c0 -w chr7:5,525,542-5,543,028

KeyError: 'chr'

Dear Wouter,

I am trying to run Methplotlib with the example data you add on the examples folders following your script:

methplotlib
-m examples/NA19240-methylation_ACTB_frequency.tsv
-n frequencies
-w chr7:5,525,542-5,543,028
-g examples/GRCh38-ACTB-locus.gtf.gz
--simplify

And I got this error:

Traceback (most recent call last):
File "/Applic.HPC/Easybuild/skylake/2022a/software/methplotlib/0.20.1-foss-2022a/bin/methplotlib", line 8, in
sys.exit(main())
File "/Applic.HPC/Easybuild/skylake/2022a/software/methplotlib/0.20.1-foss-2022a/lib/python3.10/site-packages/methplotlib/methplotlib.py", line 24, in main
qc.qc_plots(meth_data, window, qcpath=args.qcfile, outpath=args.outfile)
File "/Applic.HPC/Easybuild/skylake/2022a/software/methplotlib/0.20.1-foss-2022a/lib/python3.10/site-packages/methplotlib/qc.py", line 14, in qc_plots
p = Path(outpath.format(region=window.string))
KeyError: 'chr'

Could you please explain me what I am doing wrong?
Best,

Tania

Python import issue

Hi, I ran into a weird python import issue, tested with python 3.8.12 and python 3.6.13.

CMD:
methplotlib -m Tf-NS-R1_remora_fast_5hmc_5mC_CG_modified_bases.sorted.bam -n Tf-NS-R1 -w contig_3:100000-200000 -f /data/eric/NanoporeAssemblies/ref/Tf_reference.fasta

Error:

Traceback (most recent call last):
  File "/home/eric/miniconda3/envs/py3.6/bin/methplotlib", line 8, in <module>
    sys.exit(main())
  File "/home/eric/miniconda3/envs/py3.6/lib/python3.6/site-packages/methplotlib/methplotlib.py", line 36, in main
    minqual=args.minqual,  # only for input in bam/cram format
  File "/home/eric/miniconda3/envs/py3.6/lib/python3.6/site-packages/methplotlib/methplotlib.py", line 63, in meth_browser
    annotation=bool(bed or gtf))
  File "/home/eric/miniconda3/envs/py3.6/lib/python3.6/site-packages/methplotlib/utils.py", line 250, in create_subplots
    return plotly.subplots.make_subplots(
AttributeError: module 'plotly' has no attribute 'subplots'

I was able to get past the issue by adding import plotly.subplots to utils.py, after which the rest of the program finished without any issue.

Change header in read_meth_freq() function

Hi wdecoster, I just wanted to update you that with the newest version of nanopolish, 'num_cpgs_in_group' has changed to 'num_motifs_in_group'. Changing this in your code allows the library to work fine for the browser.

Thanks,
Dennis

No content in the output image and Error reporting

Hi, I get an error as follow:

1,
my command: ~/miniconda3/envs/OSCC/bin/methplotlib -m /NAS/wg_xialin/pancancer/raw_data/oral/fast5/yyl.T/yyl.T_methy.tsv /NAS/wg_hl/pancancer/OSCC/Methylation/f5c_meth/OSCC3/OSCC3.meth_cov10_freq.format.tsv -w chr1:99678000-99688500 -n calls frequencies --simplify

error:
Input file /NAS/wg_hl/pancancer/OSCC/Methylation/f5c_meth/OSCC3/OSCC3.meth_cov10_freq.format.tsv not recognized!

Detailed error:
Traceback (most recent call last):
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1871, in _agg_py_fallback
res_values = self.grouper.agg_series(ser, alt, preserve_dtype=True)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/groupby/ops.py", line 850, in agg_series
result = self._aggregate_series_pure_python(obj, func)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/groupby/ops.py", line 871, in _aggregate_series_pure_python
res = func(group)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 2377, in
alt=lambda x: Series(x).mean(numeric_only=numeric_only),
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/series.py", line 6221, in mean
return NDFrame.mean(self, axis, skipna, numeric_only, **kwargs)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/generic.py", line 11978, in mean
return self._stat_function(
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/generic.py", line 11935, in _stat_function
return self._reduce(
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/series.py", line 6129, in _reduce
return op(delegate, skipna=skipna, **kwds)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/nanops.py", line 147, in f
result = alt(values, axis=axis, skipna=skipna, **kwds)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/nanops.py", line 404, in new_func
result = func(values, axis=axis, skipna=skipna, mask=mask, **kwargs)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/nanops.py", line 720, in nanmean
the_sum = _ensure_numeric(the_sum)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/nanops.py", line 1693, in _ensure_numeric
raise TypeError(f"Could not convert string '{x}' to numeric")
TypeError: Could not convert string 'chr1' to numeric

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/wg_hl/miniconda3/envs/OSCC/bin/methplotlib", line 10, in
sys.exit(main())
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/methplotlib/methplotlib.py", line 16, in main
meth_data = get_data(args.methylation, args.names, window, args.smooth)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/methplotlib/import_methylation.py", line 77, in get_data
return [read_meth(f, n, window, smoothen) for f, n in zip(methylation_files, names)]
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/methplotlib/import_methylation.py", line 77, in
return [read_meth(f, n, window, smoothen) for f, n in zip(methylation_files, names)]
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/methplotlib/import_methylation.py", line 56, in read_meth
.mean()
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 2375, in mean
result = self._cython_agg_general(
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1926, in _cython_agg_general
new_mgr = data.grouped_reduce(array_func)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/internals/managers.py", line 1428, in grouped_reduce
applied = sb.apply(func)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/internals/blocks.py", line 366, in apply
result = func(self.values, **kwargs)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1923, in array_func
result = self._agg_py_fallback(how, values, ndim=data.ndim, alt=alt)
File "/home/wg_hl/miniconda3/envs/OSCC/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1875, in _agg_py_fallback
raise type(err)(msg) from err
TypeError: agg function failed [how->mean,dtype->object]

2, I have modified the command to the following:
~/miniconda3/envs/OSCC/bin/methplotlib -m /NAS/wg_xialin/pancancer/raw_data/oral/fast5/yyl.T/yyl.T_methy.tsv /NAS/wg_hl/pancancer/OSCC/Methylation/f5c_meth/OSCC3/OSCC3.meth_cov10_freq.format.tsv -w 1:99678000-99688500 -n calls frequencies --simplify

but no content in the output image. May I ask what the reason is and how can I solve it. Thanks.

problem with

Hello

I got following error running the example: AttributeError: module 'plotly' has no attribute 'subplots'
Adding import plotly.subplots to utils.py solved the problem.
I'm using plotly 5.13.0 and Python 3.8.3.

Kind regards
Stefan

mehplotlib having trouble finding sklearn

So this issue may be entirely on my end, or may be that methplotlib doesn't play well with mamba, but it's having issues finding my sklearn module. Here are the commands I used to install:

mamba create -n methplotlib pip
conda activate methplotlib
pip install methplotlib

but when I try to use it:

methplotlib -h
Traceback (most recent call last):
File "/home/matthew/anaconda3/envs/methplotlib/bin/methplotlib", line 5, in
from methplotlib.methplotlib import main
File "/home/matthew/anaconda3/envs/methplotlib/lib/python3.10/site-packages/methplotlib/methplotlib.py", line 1, in
import methplotlib.plots as plots
File "/home/matthew/anaconda3/envs/methplotlib/lib/python3.10/site-packages/methplotlib/plots.py", line 4, in
from sklearn.preprocessing import MinMaxScaler
ModuleNotFoundError: No module named 'sklearn'

I checked to make sure sklearn was installed:
pip install sklearn
Requirement already satisfied: sklearn in /home/matthew/anaconda3/envs/methplotlib/lib/python3.10/site-packages (0.0.post1)

Thoughts?

Unable to install using pip

Hi there!

I tried to install methplotlib using pip (pip install methplotlib) but it says:

Could not find a version that satisfies the requirement methplotlib (from versions: )
No matching distribution found for methplotlib

I am not sure how to install it otherwise. Any suggestion will be appreciated. Thank you!

Color modification frequency

Hi,

Very nice tool for the methylation visualization. But I cannot find what the color of the line that indicates the modification frequency represents. As the line is one consistent color, even when it goes up or down, it seems not to correlate with the likelihood. The lines have different colors (blue, orange, dark red) in different plots.

Thank you.

KeyError: "tag 'MM' not present"

HI @wdecoster ,

I've been trying to use methplotlib using guppy calls (ie. through ont-cram).

I managed to use the script you recommend from here, and follow the script author's post-modifications:

python extract_methylation_fast5_to_sam.py -V --fastq header.sam -o modcalls_pass.fastq \ --failed_reads modcalls_fail.fastq -L -F -- PAD64960_*.fast5 RGID=$(sed -e '/^@RG/!d' header.sam) minimap2 -x map-ont -y -a GRCh38_no_alt.fasta modcalls_pass.fastq | samtools addreplacerg -r "${RGID}" /dev/stdin | samtools sort -O cram --reference GRCh38_no_alt.fasta -o PAD64960.minimap2.sort.cram /dev/stdin samtools index PAD64960.minimap2.sort.cram

However, after running the following command, the error below pops-up:

$ methplotlib -m <indexed-cram> -o <html> -f <reference> -n <label> -w <coord>

Input file stock_ont.cram not recognized! Detailed error: Traceback (most recent call last): File "/home/luna.kuleuven.be/u0117540/.local/bin/methplotlib", line 11, in <module> sys.exit(main()) File "/home/luna.kuleuven.be/u0117540/.local/lib/python3.6/site-packages/methplotlib/methplotlib.py", line 18, in main meth_data = get_data(args.methylation, args.names, window, args.smooth) File "/home/luna.kuleuven.be/u0117540/.local/lib/python3.6/site-packages/methplotlib/import_methylation.py", line 161, in get_data return [read_meth(f, n, window, smoothen) for f, n in zip(methylation_files, names)] File "/home/luna.kuleuven.be/u0117540/.local/lib/python3.6/site-packages/methplotlib/import_methylation.py", line 161, in <listcomp> return [read_meth(f, n, window, smoothen) for f, n in zip(methylation_files, names)] File "/home/luna.kuleuven.be/u0117540/.local/lib/python3.6/site-packages/methplotlib/import_methylation.py", line 36, in read_meth return parse_ont_cram(filename, name, window) File "/home/luna.kuleuven.be/u0117540/.local/lib/python3.6/site-packages/methplotlib/import_methylation.py", line 106, in parse_ont_cram for mod, positions, quals in get_modified_reference_positions(read): File "/home/luna.kuleuven.be/u0117540/.local/lib/python3.6/site-packages/methplotlib/import_methylation.py", line 124, in get_modified_reference_positions basemod = read.get_tag('MM').split(',', 1)[0] File "pysam/libcalignedsegment.pyx", line 2399, in pysam.libcalignedsegment.AlignedSegment.get_tag File "pysam/libcalignedsegment.pyx", line 2438, in pysam.libcalignedsegment.AlignedSegment.get_tag KeyError: "tag 'MM' not present"

Any suggestions? My guess is that despite community are working towards adding MM/MP tags to (S/B/C)AM, not all parsers can recognize it.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.