Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling ambiguous codons #9

Open
harika-shiats opened this issue Dec 4, 2024 · 5 comments
Open

Handling ambiguous codons #9

harika-shiats opened this issue Dec 4, 2024 · 5 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@harika-shiats
Copy link

when i run the following viz.plot_ca_aa_freq_aa(in_file, 11,) I get the following error
TypeError Traceback (most recent call last)
Cell In[39], line 4
2 import pandas as pd
3 in_file = "C:/Users/aravi/Desktop/codonU/At/At_CKX_Prot.txt"
----> 4 viz.plot_ca_aa_freq_gene(in_file, 11,scale =str, min_len_threshold=66, n_components=2,organism_name= "Arabidopsis thaliana", save_image= True, folder_path= "C:/Users/aravi/Desktop/codonU/At" )

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\CodonU\vizualizer\plot_ca_aa_freq_gene.py:31, in plot_ca_aa_freq_gene(handle, genetic_table_num, scale, min_len_threshold, n_components, organism_name, save_image, folder_path)
29 cont_table.replace(0, 0.000001, inplace=True)
30 ca = ca_aa(cont_table, n_components)
---> 31 genes = ca.row_coordinates(cont_table)
33 if scale == 'aroma':
34 color_bar = [ProteinAnalysis(str(prot.seq)).aromaticity() for prot in
35 filter_reference(parse(handle, 'fasta'), min_len_threshold, 'aa')]

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\prince\utils.py:28, in check_is_dataframe_input..wrapper(*args, **kwargs)
24 if not isinstance(X, pd.DataFrame):
25 raise ValueError(
26 f"The X argument must be a pandas DataFrame, but got {type(X).name}"
27 )
---> 28 return func(*args, **kwargs)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\prince\ca.py:19, in select_active_columns..impl(self, X, *method_args, **method_kwargs)
16 @functools.wraps(method)
17 def impl(self, X=None, *method_args, **method_kwargs):
18 if hasattr(self, "active_cols
") and isinstance(X, pd.DataFrame):
---> 19 return method(self, X[self.active_cols
], *method_args, **method_kwargs)
20 return method(self, X, *method_args, **method_kwargs)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\prince\ca.py:159, in CA.row_coordinates(self, X)
155 else:
156 X = X / X.sum(axis=1)
158 return pd.DataFrame(
--> 159 data=X @ sparse.diags(self.col_masses_.to_numpy() ** -0.5) @ self.svd_.V.T,
160 index=pd.Index(row_names, name=index_name),
161 )

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\sparse_base.py:636, in spmatrix.rmatmul(self, other)
633 if isscalarlike(other):
634 raise ValueError("Scalar operands are not allowed, "
635 "use '*' instead")
--> 636 return self._rmul_dispatch(other)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\sparse_base.py:614, in spmatrix._rmul_dispatch(self, other)
612 except AttributeError:
613 tr = np.asarray(other).transpose()
--> 614 ret = self.transpose()._mul_dispatch(tr)
615 if ret is NotImplemented:
616 return NotImplemented

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\sparse_base.py:532, in spmatrix._mul_dispatch(self, other)
530 return self._mul_vector(other.ravel()).reshape(M, 1)
531 elif other.ndim == 2 and other.shape[0] == N:
--> 532 return self._mul_multivector(other)
534 if isscalarlike(other):
535 # scalar value
536 return self._mul_scalar(other)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\sparse_base.py:600, in spmatrix._mul_multivector(self, other)
599 def _mul_multivector(self, other):
--> 600 return self.tocsr()._mul_multivector(other)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\sparse_compressed.py:498, in _cs_matrix._mul_multivector(self, other)
494 M, N = self.shape
495 n_vecs = other.shape[1] # number of column vectors
497 result = np.zeros((M, n_vecs),
--> 498 dtype=upcast_char(self.dtype.char, other.dtype.char))
500 # csr_matvecs or csc_matvecs
501 fn = getattr(_sparsetools, self.format + '_matvecs')

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\sparse_sputils.py:61, in upcast_char(*args)
59 if t is not None:
60 return t
---> 61 t = upcast(*map(np.dtype, args))
62 _upcast_memo[args] = t
63 return t

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\sparse_sputils.py:53, in upcast(*args)
50 _upcast_memo[hash(args)] = t
51 return t
---> 53 raise TypeError('no supported conversion for types: %r' % (args,))

TypeError: no supported conversion for types: (dtype('float64'), dtype('O'))

kindly, let me know how to resolve this.

@SouradiptoC
Copy link
Owner

Can you check if the infile you are providing is in .fasta format and have no ambiguous codons?

@harika-shiats
Copy link
Author

harika-shiats commented Dec 6, 2024

The file is in .txt format and it has ambiguous codons in it

@harika-shiats
Copy link
Author

harika-shiats commented Dec 6, 2024 via email

@SouradiptoC
Copy link
Owner

I'm sorry mate, CodonU is not compatible with ambiguous codons...

@SouradiptoC SouradiptoC changed the title TypeError Handling ambiguous codons Dec 6, 2024
@SouradiptoC
Copy link
Owner

If you want to have this functionality, please state the use cases and expected results for handling ambiguous codons

@SouradiptoC SouradiptoC added enhancement New feature or request question Further information is requested labels Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants