open2c/bioframe

subtract error in windows

Closed this issue · 1 comments

In windows, if there are an even number of chromosomes, subtract can work properly. But if there are an odd number of chromosomes, subtract will raise an error. And if in linux, both can work well.
Here is my code:

import bioframe as bf
import pandas as pd
# even number of chromosomes
aa = pd.DataFrame([['1', 66, 99], ['2',32,68]], columns = ['chrom','start','end'])
bb = pd.DataFrame([['1', 42, 99], ['2',32,68]], columns = ['chrom','start','end'])
bf.subtract(bb, aa)
# odd number of chromosomes
bb = pd.DataFrame([['1', 42, 99]], columns = ['chrom','start','end'])
aa = pd.DataFrame([['1', 66, 99]], columns = ['chrom','start','end'])
bf.subtract(bb, aa)

Here is the error raised in windows:
image

And here is it shows in linux:
image

My software version:
bioframe 0.4.1
numpy 1.25.2
pandas 2.0.3

I checked the traceback, a bioframe (bf.from_any({i: np.iinfo(np.int64).max for i in all_chroms}, name_col='name', cols=('chrom', 'start', 'end'))) will be created first, and then compare the length of itself and its merged bioframe to check is_overlapping.
In windows, if merge the bioframe, all the end position will change into -1, so the length of the merged bioframe will always be a negative number. While the length of the raw bioframe will be a positive number if the chromosome number is odd, so it rasied the error. And in linux, merge won't change the end postion, so the length of both bioframe is the same.

I tried to change the code in bioframe.ops line 768 and 769 into :
df_group[sk].values.astype(np.int64),
df_group[ek].values.astype(np.int64),
then it can run correctly in windows.
But I'm not sure it's a correct way to solve it, so could you take a look in it?
Thanks!

Hi, please try updating to the latest bioframe 0.6.1 -- we don't reproduce the error with the current code.
Closing for now but feel free to reopen !
Thanks!