Giter Site home page Giter Site logo

Comments (2)

nvictus avatar nvictus commented on September 27, 2024 2

Actually, there is no discrepancy.

The "as-pixels" selector clr.matrix(balance=False, as_pixels=True) only returns the upper triangle portion of the global contact matrix, including the main diagonal, which will correspond to what you see in a pairs file.

clr.matrix(balance=False) returns a numpy array of the full contact matrix, including the lower triangle portion as well. At lower resolutions, more counts get absorbed into the main diagonal, which naturally changes the way these add up.

You can validate this:

for res in cooler.fileops.list_coolers("test.mcool"):
    clr = cooler.Cooler(f"test.mcool::{res}")   
        
    df = clr.matrix(balance=False, as_pixels=True).fetch("chrX(mat)")
    diag_sum = df[df['bin1_id'] == df['bin2_id']]['count'].sum()
    upper_sum = df[df['bin1_id'] != df['bin2_id']]['count'].sum()
    array_sum = clr.matrix(balance=False).fetch("chrX(mat)").sum()
        
    assert(array_sum == diag_sum + 2*upper_sum)

Or by inspecting or visualizing the two results.

from cooler.

skelviper avatar skelviper commented on September 27, 2024

Oh, I forgot about the issue with the upper triangle, that was really silly of me. Initially, when I saw that the matrix sum was different under different resolutions, I thought there would be some problems. Thank you so much for your help!

from cooler.

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.