Avoiding the empty gray box
See original GitHub issueI am a new user of HiGlass, and I am trying to use it to visualize an arbitrary numpy matrix, following the example given in the “Jupyter examples” page. When I first loaded my matrix, I just got an empty viewport, like this:
After experimenting for a bit, I learned that it was possible for me see the matrix if I kept only a small submatrix and rescaled the values to a much smaller range. Here is what I get:
I achieved this result by extracting a submatrix of size 2000x2000 and raising the entire matrix to the power 0.1. I find that if I use all of the 82548 rows of the matrix or if I expand the range of values to the original range (0 to 2166895104), then I am back to the grey screen. Selecting “zoom to extent” doesn’t solve the problem.
Is there something I can do to be able to visualize this entire matrix?
Here’s the code:
import scipy.sparse as sparse
compressed_matrix_file="DIA-S4-1.npz"
noisy_sparse = sparse.load_npz(compressed_matrix_file).tocsr()
# load the whole matrix
noisy = noisy_sparse.toarray()
# load part of the matrix
rt_min = 0
rt_max = 2000
mz_min = 38000
mz_max = 40000
noisy = noisy_sparse.toarray()[rt_min:rt_max]
noisy = np.transpose(noisy)[mz_min:mz_max]
print(noisy.shape)
noisy = np.power(noisy, 1/10)
print(noisy.min(), noisy.max())
ts = Tileset(
tileset_info=lambda: npmatrix.tileset_info(noisy),
tiles=lambda tids: npmatrix.tiles_wrapper(noisy, tids)
)
display, server, viewconf = higlass.display([
View([
Track(track_type='top-axis', position='top'),
Track(track_type='left-axis', position='left'),
Track(track_type='heatmap',
position='center',
tileset=ts,
height=250),
])
])
display
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
Yes, after I installed the new version it works. Thanks!
Interesting… you must have clodius installed because it’s a dependency of higlass-python. And the tiles function here,
npmatrix.tileset_info
comes from the clodius package.Are you using the same virtual environment for your notebook and the place you tried installing clodius?
I just issued a new release so you can now do
pip install clodius>=0.17.1
to get the latest version.