-
As stated in the doc |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Not sure this is exactly on point, but I'm working on supporting fancy indexing within a new Rust project. I'm porting Bed-Reader, our genomics program, from Python to Rust. The program reads 2-D data from a format called PLINK Bed files. The data can be bigger than 1 million individuals (rows) by 1 million DNA locations (columns). When the file is large, users want read just a slice at a time. The solution I'm creating supports indexing by nothing ("read all"), a number, a negative number (read from end), a vector or array of indexes (including negatives), any Rust range, any ndarray slice, Boolean vectors or arrays. I've put some examples below. The approach uses a builder pattern. Behind the scenes, it automatically converts all the supported indexing methods into an enum called Index. That gets converted to a vector of indexes when applied to an ndarray of known size. The code is open source. Let me know if there is interest making this its own crate.
Read individual (samples) from 20 to 30 and every second SNP (variant).
Read every value in chromosome 5.
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for your proposal! The Bed-Reader seems to be a very interesting project. use ndarray::Axis;
// Emulate the NumPy data[index]
data.index_axis(Axis(0), index) |
Beta Was this translation helpful? Give feedback.
Thanks a lot for your proposal! The Bed-Reader seems to be a very interesting project.
For my problem, is solve it using the
index_axis
method. It's seems to work find for now.