perslab / CELLEX

CELLEX (CELL-type EXpression-specificity)
GNU General Public License v3.0
37 stars 9 forks source link

[BUG]: Error saving summary data #31

Closed dah77 closed 2 years ago

dah77 commented 2 years ago

I get an error when I try to save summary data from an ESObject:

eso.summary_data.save()

I get this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_1017639/1709116986.py in <module>
      1 # Save summary data
----> 2 eso.summary_data.save()

... lib/python3.8/site-packages/cellex/summarydata.py in save(self, dir_name, verbose)
    190             att = getattr(self, s)
    191             if isinstance(att, pd.DataFrame) and s != "data":
--> 192                 fp = "{}/summarystat.{}.csv.gz".format(dir_name, self.name, s)
    193                 att.to_csv(fp, compression="gzip")
    194                 if verbose:

AttributeError: 'SummaryData' object has no attribute 'name'

It looks like there are too many parameters provided for the filename.

I am using CELLEX version 1.2.1

tstannius commented 2 years ago

Hi Daniel!

Thanks for submitting this bug - it is highly appreciated :-) You are correct, there are too many parameters - specifically because the object attribute self.name does not exist. I will try to see if I can submit a hotfix soon.

As a workaround, you should be able to do something like this:

eso.summary_data.mean.to_csv("summarystat.mean.csv.gz", compression="gzip")
eso.summary_data.n_cells_per_anno.to_csv("summarystat.n_cells_per_anno.csv.gz", compression="gzip")
eso.summary_data.n_nonzero.to_csv("summarystat.n_nonzero.csv.gz", compression="gzip")
eso.summary_data.variance.to_csv("summarystat.variance.csv.gz", compression="gzip")
dah77 commented 2 years ago

Hi Tobias, Thanks for your feedback and the workaround! Best Daniel

tstannius commented 2 years ago

Fixed by https://github.com/perslab/CELLEX/commit/5b41b0505c734da42dc1b694b4f8aa46712ac9a8

Available in release https://github.com/perslab/CELLEX/releases/tag/v1.2.2

Closing.