8000 `to_bed` reorders bed columns · Issue #274 · pyranges/pyranges · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

to_bed reorders bed columns #274

New issue

Have a question about t 8000 his project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fairliereese opened this issue Jul 20, 2022 · 1 comment
Open

to_bed reorders bed columns #274

fairliereese opened this issue Jul 20, 2022 · 1 comment

Comments

@fairliereese
Copy link
Contributor

I'm having trouble with PyRanges reordering columns in my bed file when I try to write it. Here's a minimal example:

import pandas as pd
import pyranges as pr

chrs = [1,1,1]
starts = [1,1,1]
ends = [2,3,4]
st = ['+', '+', '+']
other1 = [1,1,1]
other2 = [2,2,2]

df = pd.DataFrame()
df['Chromosome'] = chrs
df['Start'] = starts
df['End'] = ends
df['Strand'] = st
df['other1'] = other1
df['other2'] = other2

df = pr.PyRanges(df)
df.head()
df.to_bed('test_example.bed')

Output from df.head():

Screen Shot 2022-07-20 at 4 34 49 PM

Heading test_example.bed:
Screen Shot 2022-07-20 at 4 35 23 PM

As you can see, the columns have been swapped. Any idea if this behavior can be rectified?

@fairliereese fairliereese changed the title to_bed reorders non-canonical columns to_bed reorders non-canonical bed columns Jul 20, 2022
@fairliereese
Copy link
Contributor Author

Update: This also fails when you add canonical bed columns:

import pandas as pd
import pyranges as pr

chrs = [1,1,1]
starts = [1,1,1]
ends = [2,3,4]
st = ['+', '+', '+']
other1 = [1,1,1]
other2 = [2,2,2]

df = pd.DataFrame()
df['Chromosome'] = chrs
df['Start'] = starts
df['End'] = ends
df['Strand'] = st
df['ThickStart'] = other1
df['ThickEnd'] = other2

df = pr.PyRanges(df)
df.to_bed('test_example.bed')

Screen Shot 2022-07-21 at 8 59 57 AM

vs.

Screen Shot 2022-07-21 at 9 00 15 AM

@fairliereese fairliereese changed the title to_bed reorders non-canonical bed columns to_bed reorders bed columns Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0