Code Monkey home page Code Monkey logo

Comments (2)

Blosberg avatar Blosberg commented on June 9, 2024 1

Thanks for developing this excellent resource.
On this point, I'm happy with the current solution posted on readthedocs: pr.PyRanges(pandas.read_table(f)) , however, in terms of being 'too strict', using this appreach did give me the following error message:

The dataframe does not have all the columns Chromosome, Start and End

Which surprised me, until I realized that the columns were "chrom", "start", and "end" (lower-case), and didn't match. The pr.read_bed function was much more forgiving for variations on these names.

Of course I can manually change these to match the needed "Chromosome", "Start"/"End"(capitalized), but "chrom/start/end" are the standard output from bedtools functions like unionbedg, etc.

With the current solution based on pr.PyRanges(pandas.read_table(f)) is there a way to accommodate column labels like this? In the long run, it would be ideal if the read_bedlike (or whatever) could allow for these column labels so that it could work smoothly together with bedtools (which is pretty important for anyone working with bed-like files).

Thanks again for this project, it looks really promising.

from pyranges.

endrebak avatar endrebak commented on June 9, 2024

DataFrames can only have one name per column. Therefore I cannot allow "chrom" and "Chromosome" to refer to the same column.

If I allowed pyranges to have aliases for column names (start and Start) code that used the dataframes underlying the pyranges would break since no aliasing-code is implemented in pandas.

One possibility is to write a function to read bedtools-like data:

def read_bedtools(f):
    df = pd.read_table(f)
    df = df.rename(columns={"chrom": "Chromosome", "start": "Start", "end": "End", "strand": "Strand"})
    return pr.PyRanges(df)

# the opposite for write_bedtools

Thanks for the question and the kind words btw.

from pyranges.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.