Skip to content

AttributeError from gene names #173

@galicae

Description

@galicae

Hi Alex! very nice to see SAMap getting some love and the codebase being modernized. I was trying to run some older code, and had an issue running SAMap. My environment is on Python 3.11.14, with Numpy v2.3.5, SciPy 1.17.0 and Pandas 3.0.0.

In particular, when I call the SAMap function

sm = SAMAP(sams, f_maps = base + "aln/",)

I get the following attribute error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[9], [line 3](vscode-notebook-cell:?execution_count=9&line=3)
      1 sams = {"afas": afas, "pdum": pdum}
----> [3](vscode-notebook-cell:?execution_count=9&line=3) sm = SAMAP(
      4         sams,
      5         f_maps = base + "aln/",
      6     )

File /opt/homebrew/Caskroom/miniforge/base/envs/samap_minimal/lib/python3.11/site-packages/samap/core/mapping.py:170, in SAMAP.__init__(self, sams, f_maps, names, keys, resolutions, gnnm, save_processed, eval_thr)
    167     sams[sid] = sam
    169 if gnnm is None:
--> 170     gnnm_matrix, gns, gns_dict = _calculate_blast_graph(
    171         ids, f_maps=f_maps, reciprocate=True, eval_thr=eval_thr
    172     )
    173     if names is not None:
    174         gnnm_matrix, gns_dict, gns = _coarsen_blast_graph(gnnm_matrix, gns, names)

File /opt/homebrew/Caskroom/miniforge/base/envs/samap_minimal/lib/python3.11/site-packages/samap/core/mapping.py:965, in _calculate_blast_graph(ids, f_maps, eval_thr, reciprocate)
    963 A.index = pd.Index(gnind[A.index].values.flatten())
    964 B.index = pd.Index(gnind[B.index].values.flatten())
--> 965 A[A.columns[0]] = gnind[A.iloc[:, 0].values.flatten()].values.flatten()
    966 B[B.columns[0]] = gnind[B.iloc[:, 0].values.flatten()].values.flatten()
    968 Arows = np.vstack((A.index, A.iloc[:, 0], A.iloc[:, i3])).T

AttributeError: 'StringArray' object has no attribute 'flatten'

I tried the offending part with the example data:

A=pd.read_csv('/path/to/repos/SAMap/example_data/maps/plsc/pl_to_sc.txt',sep='\t',index_col=0,header=None)
B=pd.read_csv('/path/to/repos/SAMap/example_data/maps/plsc/sc_to_pl.txt',sep='\t',index_col=0,header=None)
data = B.iloc[:, 0].values.flatten()

and get the same AttributeError so I think it's not a formatting issue or table reading issue on my side. Any ideas? In my environment I am getting a StringArray for B.iloc[:, 0].values, which is already one-dimensional and iterable, so I know how to fix locally, but I wonder if this is intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions