Skip to content
New issue

Have a question about this 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

Creating sparse matrix from hdf5 file #186

Open
rbutleriii opened this issue Nov 19, 2021 · 0 comments
Open

Creating sparse matrix from hdf5 file #186

rbutleriii opened this issue Nov 19, 2021 · 0 comments

Comments

@rbutleriii
Copy link

Hello, I am looking at a large hdf5 file and trying to extract a matrix convert it to a sparse matrix. The source file and code below. It works for smaller slices (i.e [1:5, 1:5]) but when I try to load the whole thing I get an args_regularity_evaluation error

library(hdf5r)
library(Matrix)
fn = "expression_matrix.hdf5"
if(!file.exists(fn)){
  site = "https://idk-etl-prod-download-bucket.s3.amazonaws.com"
  dataset = "aibs_mouse_ctx-hpf_10x"
  # print(paste(site, dataset, i, sep="/"))
  system2("wget", args=paste(site, dataset, fn, sep="/"))
} else { print(paste(fn, "exists, skipping")) }
a = H5File$new(fn, mode="r")
a[['data']]
# b = Matrix(a[['data/counts']][1:5, 1:5], 
           # dimnames=list(a[['data/samples']][1:5], a[['data/gene']][1:5]))
b = Matrix(a[['data/counts']][], 
           dimnames=list(a[['data/samples']][], a[['data/gene']][]))
# Error in args_regularity_evaluation(args = args, ds_dims = simple_extent$dims,  :
#  Number of arguments not equal to number of dimensions: 1 vs. 2

hdf5 file info

Class: H5Group
Filename: /oak/stanford/scg/lab_flongo/reference/allen_brain_atlas/mouse_cortex/expression_matrix.hdf5
Group: /data
Listing:
    name    obj_type    dataset.dims dataset.type_class
  counts H5I_DATASET 1169320 x 31053        H5T_INTEGER
    gene H5I_DATASET           31053         H5T_STRING
 samples H5I_DATASET         1169320         H5T_STRING
   shape H5I_DATASET               2        H5T_INTEGER
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