jon-xu / scSplit

Genotype-free demultiplexing of pooled single-cell RNA-Seq, using a hidden state model for identifying genetically distinct samples within a mixed population.
MIT License
39 stars 9 forks source link

pandas "append" function for DataFrame object is deprecated #27

Closed G3N0M3 closed 9 months ago

G3N0M3 commented 9 months ago

While running scSplit run, I came to an error that there is no "append" function for DataFrame objects.

I found out that the append function is deprecated since version 1.4.0, and substituted with "concat".

I was able to get results with some warnings and using pandas version 2.1.3, with some modifications in line 588 and 593.

assignments = pd.DataFrame()
for n in range(num):
    assignment = pd.DataFrame()
    assignment['Barcode'] = model.reassigned[n]
    if n != model.doublet:
        assignment['Cluster'] = 'SNG-' + str(n)
        assignments = pd.concat([assignments, assignment])
        if doublets != 0:   # if doublet cluster is expected
            assignment = pd.DataFrame()
            assignment['Barcode'] = model.reassigned[model.doublet]
            assignment['Cluster'] = 'DBL-' + str(model.doublet)
            assignments = pd.concat([assignments, assignment])
            assignments.to_csv(os.path.join(args.out, r'scSplit_result.csv'), sep='\t', index=False)
            model.P_s_c.to_csv(os.path.join(args.out, r'scSplit_P_s_c.csv'))
            with open(os.path.join(args.out, r'scSplit_dist_variants.txt'), 'w') as logfile:
                for item in model.dist_variants:
                    logfile.write(str(item) + '\n')
                    model.dist_matrix.to_csv(os.path.join(args.out, r'scSplit_dist_matrix.csv'), float_format='%.0f')
                    model.pa_matrix.to_csv(os.path.join(args.out, r'scSplit_PA_matrix.csv'), float_format='%.0f')

Can your side confirm that the modification is valid and will produce the intended results? Thanks!

jon-xu commented 9 months ago

Hi Eunjun,

We developed on earlier version of pandas.

Thanks for letting us know the depreciation of append function.

Based on pandas documentation, I think your amendment is consistent with previous append function.

Unfortunately we don’t have plan to catch up all updates in different packages. Thus we couldn’t test your amendments. Sorry about that!

Good luck!

Jon

On 3 Dec 2023, at 22:23, Eunjun Choi @.***> wrote:



While running scSplit run, I came to an error that there is no "append" function for DataFrame objects.

I found out that the append function is deprecated since version 1.4.0, and substituted with "concat".

I was able to get results with some warnings and using pandas version 2.1.3

assignments = pd.DataFrame() for n in range(num): assignment = pd.DataFrame() assignment['Barcode'] = model.reassigned[n] if n != model.doublet: assignment['Cluster'] = 'SNG-' + str(n) assignments = pd.concat([assignments, assignment]) if doublets != 0: # if doublet cluster is expected assignment = pd.DataFrame() assignment['Barcode'] = model.reassigned[model.doublet] assignment['Cluster'] = 'DBL-' + str(model.doublet) assignments = pd.concat([assignments, assignment]) assignments.to_csv(os.path.join(args.out, r'scSplit_result.csv'), sep='\t', index=False) model.P_s_c.to_csv(os.path.join(args.out, r'scSplit_P_s_c.csv')) with open(os.path.join(args.out, r'scSplit_dist_variants.txt'), ' w') as logfile: for item in model.dist_variants: logfile.write(str(item) + '\n') model.dist_matrix.to_csv(os.path.join(args.out, r'scSplit_dist_ma trix.csv'), float_format='%.0f') model.pa_matrix.to_csv(os.path.join(args.out, r'scSplit_PA_matrix .csv'), float_format='%.0f')

Can your side confirm that the modification is valid and will produce the intended results? Thanks!

— Reply to this email directly, view it on GitHubhttps://github.com/jon-xu/scSplit/issues/27, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJXMHDC7W3WFMTGUFWXKWR3YHRVK3AVCNFSM6AAAAABAEX364KVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZDENBZGY3TONY. You are receiving this because you are subscribed to this thread.Message ID: @.***>

G3N0M3 commented 9 months ago

@jon-xu Thanks!