ucsd-ccbb / NetColoc

development of network co-localization tool
MIT License
13 stars 6 forks source link

AttributeError_step17 #16

Open MaryamEO opened 7 months ago

MaryamEO commented 7 months ago

Description

I tried to follow the steps in the Python scripts using the data from the paper. But, when I got to step 17, where I needed to compute the enrichment of specific phenotypes in the NetColoc subnetwork, I got an error regarding the AttributeError.

What I Did

The command: 

# add a negative control phenotype: abnormal innate immunity: MP:0002419
# negative controls are tough here because we're dealing with development, which impacts almost everything.
MP_focal_list = ['MP:0002419']+MP_focal_brain_list
root_KO_brain_df=validation.MPO_enrichment_root(hier_df,MPO,mgi_df,MP_focal_list,G_int,verbose=True)
The output: 

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_16488/4110320689.py in ?()
----> 4 # add a negative control phenotype: abnormal innate immunity: MP:0002419
      5 # negative controls are tough here because we're dealing with development, which impacts almost everything.
      6 MP_focal_list = ['MP:0002419']+MP_focal_brain_list
      7 root_KO_brain_df=validation.MPO_enrichment_root(hier_df,MPO,mgi_df,MP_focal_list,G_int,verbose=True)

~/.conda/envs/NetColoc/lib/python3.9/site-packages/netcoloc/validation.py in ?(hier_df, MPO, mgi_df, MP_focal_list, G_int, verbose)
    167         MP_desc_focal = dict(MPO.node_attr['description'])[MP_focal]
    168 
    169         # focus the hierarchy on one branch, and look up all terms within that branch
    170         if len(MPO.parent_2_child[MP_focal])>0:
--> 171             MPO_focal = MPO.focus(MP_focal,verbose=False)
    172             focal_terms = MPO_focal.terms
    173         else:  # if the term has no children, just look at that term
    174             focal_terms=[MP_focal]

~/.conda/envs/NetColoc/lib/python3.9/site-packages/ddot/Ontology.py in ?(self, branches, genes, collapse, root, verbose)
   1987 
   1988         if collapse:
   1989             ont = ont.collapse_ontology(method='python', to_keep=ont.get_roots())
   1990 
-> 1991         df = ont.to_table(edge_attr=True)
   1992 
   1993         new_connections = []
   1994         for t in ont.terms:

~/.conda/envs/NetColoc/lib/python3.9/site-packages/ddot/Ontology.py in ?(self, output, term_2_term, gene_2_term, edge_attr, header, parent_child, clixo_format)
   2341             return df
   2342 
   2343         df = pd.DataFrame(columns=['Parent','Child',self.EDGETYPE_ATTR])
   2344         if term_2_term:
-> 2345             df = df.append(self._hierarchy_to_pandas(), ignore_index=True)
   2346         if gene_2_term:
   2347             df = df.append(self._mapping_to_pandas(), ignore_index=True)
   2348 

~/.conda/envs/NetColoc/lib/python3.9/site-packages/pandas/core/generic.py in ?(self, name)
   6289             and name not in self._accessors
   6290             and self._info_axis._can_hold_identifiers_and_holds_name(name)
   6291         ):
   6292             return self[name]
-> 6293         return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'
coleslaw481 commented 7 months ago

Pandas 2+ got rid of DataFrame.append() but this code wasn't updated. Until we get a fix in, a bandaid work around is to use an older version of pandas 1.4.x