Error in cancer.py file
Closed this issue · 4 comments
Hello,
After installing the cptac package I am having this problem. can you help me?
import cptac
TypeError Traceback (most recent call last)
in
----> 1 import cptac
~\anaconda3\lib\site-packages\cptac_init_.py in
30
31 # Dataset imports
---> 32 from cptac.cancers.brca import Brca
33 from cptac.cancers.ccrcc import Ccrcc
34 from cptac.cancers.coad import Coad
~\anaconda3\lib\site-packages\cptac\cancers\brca.py in
10 # limitations under the License.
11
---> 12 from cptac.cancers.cancer import Cancer
13
14 # Import various BRCA data sources
~\anaconda3\lib\site-packages\cptac\cancers\cancer.py in
23 from cptac.tools.dataframe_tools import add_index_levels, join_col_to_dataframe
24
---> 25 class Cancer:
26 NORMAL_ENDINGS = ('.N', '.C') # HNSCC data has cored normal samples marked .C
27 """Note that all cancer datasets are class objects that inherit
~\anaconda3\lib\site-packages\cptac\cancers\cancer.py in Cancer()
1000 return df
1001
-> 1002 def _format_mutations_data(self, mutations: pd.DataFrame, mutations_were_filtered: bool, show_location: bool=True, how: str="outer", quiet: bool=False, tissue_type: str="both", mutation_cols: list[str] or str=["Mutation","Location"]
1003 ) -> pd.DataFrame:
1004 """Format mutations data. Add a Sample_Status column, fill in NaNs with Wildtype_Normal or Wildtype_Tumor.
TypeError: 'type' object is not subscriptable
I'm so sorry about the inconvenience. Would you mind letting us know what version of cptac you are currently running?
Hi Sabrina,
Thank you for your answer! I'm using these versions of cptac, pandas, and, pip, conda, and numexpr:
numexpr 2.7.3
cptac 1.5.1
conda 4.14.0
pandas 2.0.3
pip 23.2.1
Excited to use this package, but I'm getting the same issue when trying to import cptac v1.5.7. Specifically:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import cptac
File ~/miniconda3/envs/cptac/lib/python3.8/site-packages/cptac/__init__.py:32
29 from cptac.utils.other_utils import df_to_tree
31 # Dataset imports
---> 32 from cptac.cancers.brca import Brca
33 from cptac.cancers.ccrcc import Ccrcc
34 from cptac.cancers.coad import Coad
File ~/miniconda3/envs/cptac/lib/python3.8/site-packages/cptac/cancers/brca.py:12
1 # Copyright 2023 Samuel Payne sam_payne@byu.edu
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
(...)
9 # See the License for the specific language governing permissions and
10 # limitations under the License.
---> 12 from cptac.cancers.cancer import Cancer
14 # Import various BRCA data sources
15 from cptac.cancers.bcm.bcmbrca import BcmBrca
File ~/miniconda3/envs/cptac/lib/python3.8/site-packages/cptac/cancers/cancer.py:25
22 from cptac.exceptions import *
23 from cptac.tools.dataframe_tools import add_index_levels, join_col_to_dataframe
---> 25 class Cancer:
26 NORMAL_ENDINGS = ('.N', '.C') # HNSCC data has cored normal samples marked .C
27 """Note that all cancer datasets are class objects that inherit
28 from cptac.cancer.
29 Therefore the same function calls exist for cptac.Brca, cptac.Gbm, etc.
30 """
File ~/miniconda3/envs/cptac/lib/python3.8/site-packages/cptac/cancers/cancer.py:1002, in Cancer()
998 df.columns.name = "Name"
1000 return df
-> 1002 def _format_mutations_data(self, mutations: pd.DataFrame, mutations_were_filtered: bool, show_location: bool=True, how: str="outer", quiet: bool=False, tissue_type: str="both", mutation_cols: list[str] or str=["Mutation","Location"]
1003 ) -> pd.DataFrame:
1004 """Format mutations data. Add a Sample_Status column, fill in NaNs with Wildtype_Normal or Wildtype_Tumor.
1005 Note: This is mostly so that the multi_join function can behave the same way as the old join functions.
1006 join_other_to_mutations does this same formatting, and should probably be refactored to use this.
(...)
1017 pandas.DataFrame: The joined dataframe, with a Sample_Status column added and NaNs filled.
1018 """
1020 # Add Sample_Status column
TypeError: 'type' object is not subscriptable