You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation lacks examples of how to generate seqlogos when ambiguous nucleotides are present.
I have sequences made of A, C, G, T and N, for which I computed frequency values in a pandas data frame:
But I'm not sure to understand exactly what I should put in background.
Then, I failed to use seqlogo.seqlogo. In particular, I feel there should be some information in the documentation about how to specify colour schemes.
To Reproduce
Some attempts with the custom alphabet:
>>> seqlogo.seqlogo(logo5, filename="/tmp/logo5.pdf", format="pdf")
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-28-b1c1bb251418> in <module>
----> 1 seqlogo.seqlogo(logo5, filename="/tmp/logo5.pdf", format="pdf")
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/seqlogo/seqlogo.py in seqlogo(pm, ic_scale, color_scheme, size, format, filename, **kwargs)
70 raise ValueError('{} color_scheme selected is not an allowed amino acid color scheme'.format(color_scheme))
71
---> 72 color_scheme = wl.std_color_schemes[color_scheme]
73
74 # Setup the format writer
KeyError: None
>>> seqlogo.seqlogo(logo5, filename="/tmp/logo5.pdf", color_scheme="classic", format="pdf")
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2890 try:
-> 2891 return self._engine.get_loc(casted_key)
2892 except KeyError as err:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
KeyError: 0
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
<ipython-input-29-37d517bbcb2a> in <module>
----> 1 seqlogo.seqlogo(logo5, filename="/tmp/logo5.pdf", color_scheme="classic", format="pdf")
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/seqlogo/seqlogo.py in seqlogo(pm, ic_scale, color_scheme, size, format, filename, **kwargs)
89 logo_format = wl.LogoFormat(pm, options)
90
---> 91 out = out_format(pm, logo_format)
92
93 # Create the file if the user supplied an filename
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/weblogo/logo_formatter.py in pdf_formatter(logodata, logoformat)
34 def pdf_formatter(logodata: LogoData, logoformat: LogoFormat) -> bytes:
35 """ Generate a logo in PDF format."""
---> 36 eps = eps_formatter(logodata, logoformat).decode()
37 gs = GhostscriptAPI()
38 return gs.convert('pdf', eps, logoformat.logo_width, logoformat.logo_height)
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/weblogo/logo_formatter.py in eps_formatter(logodata, logoformat)
162
163 if conv_factor:
--> 164 stack_height = logodata.entropy[seq_index] * std_units[logoformat.unit_name]
165 else:
166 stack_height = 1.0 # probability # pragma: no cover
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/series.py in __getitem__(self, key)
880
881 elif key_is_scalar:
--> 882 return self._get_value(key)
883
884 if (
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/series.py in _get_value(self, label, takeable)
989
990 # Similar to Index.get_value, but we do not fall back to positional
--> 991 loc = self.index.get_loc(label)
992 return self.index._get_values_for_loc(self, loc, label)
993
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2891 return self._engine.get_loc(casted_key)
2892 except KeyError as err:
-> 2893 raise KeyError(key) from err
2894
2895 if tolerance is not None:
KeyError: 0
Some attempts with the "reduced DNA" alphabet:
>>> seqlogo.seqlogo(logo6, filename="/tmp/logo6.pdf", format="pdf")
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2890 try:
-> 2891 return self._engine.get_loc(casted_key)
2892 except KeyError as err:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
KeyError: 0
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
<ipython-input-30-0a0df93d7b64> in <module>
----> 1 seqlogo.seqlogo(logo6, filename="/tmp/logo6.pdf", format="pdf")
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/seqlogo/seqlogo.py in seqlogo(pm, ic_scale, color_scheme, size, format, filename, **kwargs)
89 logo_format = wl.LogoFormat(pm, options)
90
---> 91 out = out_format(pm, logo_format)
92
93 # Create the file if the user supplied an filename
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/weblogo/logo_formatter.py in pdf_formatter(logodata, logoformat)
34 def pdf_formatter(logodata: LogoData, logoformat: LogoFormat) -> bytes:
35 """ Generate a logo in PDF format."""
---> 36 eps = eps_formatter(logodata, logoformat).decode()
37 gs = GhostscriptAPI()
38 return gs.convert('pdf', eps, logoformat.logo_width, logoformat.logo_height)
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/weblogo/logo_formatter.py in eps_formatter(logodata, logoformat)
162
163 if conv_factor:
--> 164 stack_height = logodata.entropy[seq_index] * std_units[logoformat.unit_name]
165 else:
166 stack_height = 1.0 # probability # pragma: no cover
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/series.py in __getitem__(self, key)
880
881 elif key_is_scalar:
--> 882 return self._get_value(key)
883
884 if (
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/series.py in _get_value(self, label, takeable)
989
990 # Similar to Index.get_value, but we do not fall back to positional
--> 991 loc = self.index.get_loc(label)
992 return self.index._get_values_for_loc(self, loc, label)
993
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2891 return self._engine.get_loc(casted_key)
2892 except KeyError as err:
-> 2893 raise KeyError(key) from err
2894
2895 if tolerance is not None:
KeyError: 0
>>> seqlogo.seqlogo(logo6, filename="/tmp/logo6.pdf", color_scheme="classic", format="pdf")
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2890 try:
-> 2891 return self._engine.get_loc(casted_key)
2892 except KeyError as err:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
KeyError: 0
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
<ipython-input-31-4fd2890af7d4> in <module>
----> 1 seqlogo.seqlogo(logo6, filename="/tmp/logo6.pdf", color_scheme="classic", format="pdf")
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/seqlogo/seqlogo.py in seqlogo(pm, ic_scale, color_scheme, size, format, filename, **kwargs)
89 logo_format = wl.LogoFormat(pm, options)
90
---> 91 out = out_format(pm, logo_format)
92
93 # Create the file if the user supplied an filename
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/weblogo/logo_formatter.py in pdf_formatter(logodata, logoformat)
34 def pdf_formatter(logodata: LogoData, logoformat: LogoFormat) -> bytes:
35 """ Generate a logo in PDF format."""
---> 36 eps = eps_formatter(logodata, logoformat).decode()
37 gs = GhostscriptAPI()
38 return gs.convert('pdf', eps, logoformat.logo_width, logoformat.logo_height)
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/weblogo/logo_formatter.py in eps_formatter(logodata, logoformat)
162
163 if conv_factor:
--> 164 stack_height = logodata.entropy[seq_index] * std_units[logoformat.unit_name]
165 else:
166 stack_height = 1.0 # probability # pragma: no cover
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/series.py in __getitem__(self, key)
880
881 elif key_is_scalar:
--> 882 return self._get_value(key)
883
884 if (
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/series.py in _get_value(self, label, takeable)
989
990 # Similar to Index.get_value, but we do not fall back to positional
--> 991 loc = self.index.get_loc(label)
992 return self.index._get_values_for_loc(self, loc, label)
993
~/src/bioinfo_utils/.venv/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2891 return self._engine.get_loc(casted_key)
2892 except KeyError as err:
-> 2893 raise KeyError(key) from err
2894
2895 if tolerance is not None:
KeyError: 0
Expected behavior
The documentation should explain how to deal with data containing ambiguous DNA, in particular regarding the "background" and "color_scheme" arguments, ideally including examples.
Desktop (please complete the following information):
OS: MX Linux 17 (debian-based)
Python Version: 3.8.2
NumPy Version: 1.19.2
Pandas Version: 1.1.2
matplotlib Version: 3.3.2
Additional context
I'm working using an ssh connection without X forwarding, using ipython (I replaced the prompts with standard >>> prompt in the code examples above).
The text was updated successfully, but these errors were encountered:
Describe the bug
The documentation lacks examples of how to generate seqlogos when ambiguous nucleotides are present.
I have sequences made of A, C, G, T and N, for which I computed frequency values in a pandas data frame:
I haven't found in the documentation how to have this data accepted by
seqlogo.Ppm
.By exploring the source code and experimenting, I finally found two ways to do it.
But I'm not sure to understand exactly what I should put in
background
.Then, I failed to use
seqlogo.seqlogo
. In particular, I feel there should be some information in the documentation about how to specify colour schemes.To Reproduce
Some attempts with the custom alphabet:
Some attempts with the "reduced DNA" alphabet:
Expected behavior
The documentation should explain how to deal with data containing ambiguous DNA, in particular regarding the "background" and "color_scheme" arguments, ideally including examples.
Desktop (please complete the following information):
Additional context
I'm working using an ssh connection without X forwarding, using ipython (I replaced the prompts with standard
>>>
prompt in the code examples above).The text was updated successfully, but these errors were encountered: