diff --git a/snapatac2-core/Cargo.toml b/snapatac2-core/Cargo.toml index 17b321a09..f85dffd98 100644 --- a/snapatac2-core/Cargo.toml +++ b/snapatac2-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "snapatac2-core" -version = "2.0.0" +version = "2.0.1" edition = "2021" authors = ["Kai Zhang "] description = "Rust APIs" @@ -10,7 +10,7 @@ homepage = "https://github.com/" keywords = ["single-cell", "biology"] [dependencies] -anndata = "0.3.3" +anndata = "0.4.1" anyhow = "1.0" bigtools = { version = "0.4", features = ["read", "write"] } bed-utils = "0.4.1" @@ -25,9 +25,9 @@ lexical = "6.1" log = "0.4" ndarray = { version = "0.15", features = ["rayon"] } num = "0.4" -noodles = { version = "0.70", features = ["core", "bam", "sam", "gff", "gtf"] } +noodles = { version = "0.74", features = ["core", "bam", "sam", "gff", "gtf"] } nalgebra-sparse = "0.9" -polars = { version = "0.39", features = ["ndarray", "dtype-categorical"] } +polars = { version = "0.40", features = ["ndarray", "dtype-categorical"] } rayon = "1.10" regex = "1.6" serde = "1.0" diff --git a/snapatac2-core/src/preprocessing/count_data/matrix.rs b/snapatac2-core/src/preprocessing/count_data/matrix.rs index 6c052b5ed..6475604e6 100644 --- a/snapatac2-core/src/preprocessing/count_data/matrix.rs +++ b/snapatac2-core/src/preprocessing/count_data/matrix.rs @@ -5,7 +5,7 @@ use crate::preprocessing::count_data::{ }; use super::coverage::CountingStrategy; -use anndata::{AnnDataOp, AxisArraysOp}; +use anndata::{data::DataFrameIndex, AnnDataOp}; use indicatif::{ProgressIterator, ProgressStyle}; use polars::prelude::{NamedFrom, DataFrame, Series}; use anyhow::Result; @@ -41,45 +41,33 @@ where "[{elapsed}] {bar:40.cyan/blue} {pos:>7}/{len:7} (eta: {eta})" ).unwrap(); - if adata.obsm().keys().contains(&"contact".into()) { - let data_iter = adata - .contact_count_iter(chunk_size)? - .with_resolution(bin_size) - .into_values::().map(|x| x.0).progress_with_style(style); - if let Some(adata_out) = out { - adata_out.set_x_from_iter(data_iter)?; - adata_out.set_obs_names(adata.obs_names())?; - adata_out.set_var_names(adata_out.n_vars().into())?; - } else { - adata.set_x_from_iter(data_iter)?; - adata.set_var_names(adata.n_vars().into())?; - } - } else { - let mut counts = adata - .get_count_iter(chunk_size)? - .with_resolution(bin_size) - .set_counting_strategy(counting_strategy); + let mut counts = adata + .get_count_iter(chunk_size)? + .with_resolution(bin_size) + .set_counting_strategy(counting_strategy); - if let Some(exclude_chroms) = exclude_chroms { - counts = counts.exclude(exclude_chroms); - } - if let Some(min_fragment_size) = min_fragment_size { - counts = counts.min_fragment_size(min_fragment_size); - } - if let Some(max_fragment_size) = max_fragment_size { - counts = counts.max_fragment_size(max_fragment_size); - } + if let Some(exclude_chroms) = exclude_chroms { + counts = counts.exclude(exclude_chroms); + } + if let Some(min_fragment_size) = min_fragment_size { + counts = counts.min_fragment_size(min_fragment_size); + } + if let Some(max_fragment_size) = max_fragment_size { + counts = counts.max_fragment_size(max_fragment_size); + } - let feature_names = counts.get_gindex().to_index().into(); - let data_iter = counts.into_counts::().map(|x| x.0).progress_with_style(style); - if let Some(adata_out) = out { - adata_out.set_x_from_iter(data_iter)?; - adata_out.set_obs_names(adata.obs_names())?; - adata_out.set_var_names(feature_names)?; - } else { - adata.set_x_from_iter(data_iter)?; - adata.set_var_names(feature_names)?; - } + let feature_names: DataFrameIndex = counts.get_gindex().to_index().into(); + let n_feat = feature_names.len(); + let data_iter = counts.into_counts::().map(|x| x.0).progress_with_style(style); + if let Some(adata_out) = out { + adata_out.set_n_vars(n_feat)?; + adata_out.set_x_from_iter(data_iter)?; + adata_out.set_obs_names(adata.obs_names())?; + adata_out.set_var_names(feature_names)?; + } else { + adata.set_n_vars(n_feat)?; + adata.set_x_from_iter(data_iter)?; + adata.set_var_names(feature_names)?; } Ok(()) } @@ -119,11 +107,14 @@ where } Box::new(counts.aggregate_counts_by(counter).map(|x| x.0)) }; + let n_feat = feature_names.len(); if let Some(adata_out) = out { + adata_out.set_n_vars(n_feat)?; adata_out.set_x_from_iter(data.progress_with_style(style))?; adata_out.set_obs_names(adata.obs_names())?; adata_out.set_var_names(feature_names.into())?; } else { + adata.set_n_vars(n_feat)?; adata.set_x_from_iter(data.progress_with_style(style))?; adata.set_var_names(feature_names.into())?; } @@ -206,4 +197,4 @@ where _ => panic!("id_type must be 'transcript' or 'gene'"), } Ok(()) -} \ No newline at end of file +} diff --git a/snapatac2-python/Cargo.lock b/snapatac2-python/Cargo.lock index 3d480a1a8..1dd322da7 100644 --- a/snapatac2-python/Cargo.lock +++ b/snapatac2-python/Cargo.lock @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "anndata" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb25ab5522d849dda564d6807e7cd17dac43a0fd10d14770c8f8d9b39d4a12be" +checksum = "7908551ce9d7d10e1ec90eaa697951eae25421c215c8dcb8cd8cd75270b0111f" dependencies = [ "anyhow", "flate2", @@ -84,9 +84,9 @@ dependencies = [ [[package]] name = "anndata-hdf5" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de80bddc00b2de20cafd47a662a9b0abad897742eb08cc5465348be96677f35" +checksum = "48c189e0569819cd805ab11330bb76b83b5d35b79c9cb39b3edf35eef232400d" dependencies = [ "anndata", "anyhow", @@ -251,6 +251,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bed-utils" version = "0.4.1" @@ -339,7 +345,7 @@ dependencies = [ "serde_derive", "statrs", "strum", - "strum_macros", + "strum_macros 0.25.3", "thiserror", "triple_accel", "vec_map", @@ -354,7 +360,7 @@ dependencies = [ "derive-new", "lazy_static", "regex", - "strum_macros", + "strum_macros 0.25.3", "thiserror", ] @@ -576,7 +582,7 @@ checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ "crossterm", "strum", - "strum_macros", + "strum_macros 0.25.3", "unicode-width", ] @@ -752,9 +758,9 @@ checksum = "3e02df23d5b1c6f9e69fa603b890378123b93073df998a21e6e33b9db0a32613" [[package]] name = "either" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "encode_unicode" @@ -1017,6 +1023,7 @@ dependencies = [ "ahash", "allocator-api2", "rayon", + "serde", ] [[package]] @@ -1759,9 +1766,9 @@ dependencies = [ [[package]] name = "noodles" -version = "0.70.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c7777c4301ec50202f778c15d73b88c30f9240a074f9b9a98fe7babfa5bfc8" +checksum = "8903a0299daf4f072f2e601c74c29c861abdfd2427366e727b8d8afbbde8cbcc" dependencies = [ "noodles-bam", "noodles-core", @@ -1772,9 +1779,9 @@ dependencies = [ [[package]] name = "noodles-bam" -version = "0.60.0" +version = "0.63.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "880f71c52dab49e073361e0427610e07eccea07ff48a2ecd8f133c648cb115d8" +checksum = "3ede0b1e0b8e0e03f21c692ad38473dfe95c3650317650205c29c9a682c4a5a6" dependencies = [ "bit-vec 0.6.3", "bstr", @@ -1789,9 +1796,9 @@ dependencies = [ [[package]] name = "noodles-bgzf" -version = "0.28.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff82b0fb78c11947b29ef50e8ddf0093813fa9e613af0e13dc53fc12b2dc3ea" +checksum = "13f54d4840fd26ed94103ded9524aa5fdd757255a556f24653d162c0a45c47e8" dependencies = [ "byteorder", "bytes", @@ -1801,15 +1808,18 @@ dependencies = [ [[package]] name = "noodles-core" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7336c3be652de4e05444c9b12a32331beb5ba3316e8872d92bfdd8ef3b06c282" +checksum = "c5a8c6b020d1205abef2b0fab4463a6c5ecc3c8f4d561ca8b0d1a42323376200" +dependencies = [ + "bstr", +] [[package]] name = "noodles-csi" -version = "0.32.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938d7d865a3fbb079c7855e76eb1ef0be5d285dc039fa7776622225c7f708411" +checksum = "beb1618ca2aa88662d387197a188686105d6b5e25f6959c52b766276cbfc4620" dependencies = [ "bit-vec 0.6.3", "byteorder", @@ -1820,9 +1830,9 @@ dependencies = [ [[package]] name = "noodles-gff" -version = "0.29.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9216634517bf888abb425b10f3df7857ee3f584d4e46c8d6a2bb2c84acc4e10e" +checksum = "578b6efaf5c3f029720af4c8590e34fd38e214666971d665a52e3566830170d0" dependencies = [ "indexmap 2.2.3", "noodles-bgzf", @@ -1833,9 +1843,9 @@ dependencies = [ [[package]] name = "noodles-gtf" -version = "0.25.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d4fabc2e574e80c00341685e8f4df37ae0b5a00a6fecccfd7c99eb45d5a4cf" +checksum = "126a4e1149e741808168e36fa38af871139428829d885e1ade46026ac31871c9" dependencies = [ "noodles-bgzf", "noodles-core", @@ -1844,9 +1854,9 @@ dependencies = [ [[package]] name = "noodles-sam" -version = "0.57.0" +version = "0.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0598e959a0e56fc60f11b3bc63bf11c332a530cb54883196c0eab1bd0d4b8a" +checksum = "0ec6452e8ed9f20ef043dce35e09ed58f1c34834cd941e987458a66e8fa66fa0" dependencies = [ "bitflags 2.4.2", "bstr", @@ -2187,9 +2197,9 @@ dependencies = [ [[package]] name = "polars" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea21b858b16b9c0e17a12db2800d11aa5b4bd182be6b3022eb537bbfc1f2db5" +checksum = "e148396dca5496566880fa19374f3f789a29db94e3eb458afac1497b4bac5442" dependencies = [ "getrandom", "polars-arrow", @@ -2207,9 +2217,9 @@ dependencies = [ [[package]] name = "polars-arrow" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725b09f2b5ef31279b66e27bbab63c58d49d8f6696b66b1f46c7eaab95e80f75" +checksum = "1cb5e11cd0752ae022fa6ca3afa50a14b0301b7ce53c0135828fbb0f4fa8303e" dependencies = [ "ahash", "atoi", @@ -2252,9 +2262,9 @@ dependencies = [ [[package]] name = "polars-compute" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a796945b14b14fbb79b91ef0406e6fddca2be636e889f81ea5d6ee7d36efb4fe" +checksum = "89fc4578f826234cdecb782952aa9c479dc49373f81694a7b439c70b6f609ba0" dependencies = [ "bytemuck", "either", @@ -2268,9 +2278,9 @@ dependencies = [ [[package]] name = "polars-core" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465f70d3e96b6d0b1a43c358ba451286b8c8bd56696feff020d65702aa33e35c" +checksum = "e490c6bace1366a558feea33d1846f749a8ca90bd72a6748752bc65bb4710b2a" dependencies = [ "ahash", "bitflags 2.4.2", @@ -2301,9 +2311,9 @@ dependencies = [ [[package]] name = "polars-error" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5224d5d05e6b8a6f78b75951ae1b5f82c8ab1979e11ffaf5fd41941e3d5b0757" +checksum = "08888f58e61599b00f5ea0c2ccdc796b54b9859559cc0d4582733509451fa01a" dependencies = [ "polars-arrow-format", "regex", @@ -2311,11 +2321,31 @@ dependencies = [ "thiserror", ] +[[package]] +name = "polars-expr" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4173591920fe56ad55af025f92eb0d08421ca85705c326a640c43856094e3484" +dependencies = [ + "ahash", + "bitflags 2.4.2", + "once_cell", + "polars-arrow", + "polars-core", + "polars-io", + "polars-ops", + "polars-plan", + "polars-time", + "polars-utils", + "rayon", + "smartstring", +] + [[package]] name = "polars-io" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2c8589e418cbe4a48228d64b2a8a40284a82ec3c98817c0c2bcc0267701338b" +checksum = "5842896aea46d975b425d63f156f412aed3cfde4c257b64fb1f43ceea288074e" dependencies = [ "ahash", "atoi_simd", @@ -2345,9 +2375,9 @@ dependencies = [ [[package]] name = "polars-lazy" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2632b1af668e2058d5f8f916d8fbde3cac63d03ae29a705f598e41dcfeb7f" +checksum = "e805ea2ebbc6b7749b0afb31b7fc5d32b42b57ba29b984549d43d3a16114c4a5" dependencies = [ "ahash", "bitflags 2.4.2", @@ -2355,6 +2385,7 @@ dependencies = [ "once_cell", "polars-arrow", "polars-core", + "polars-expr", "polars-io", "polars-ops", "polars-pipe", @@ -2368,13 +2399,13 @@ dependencies = [ [[package]] name = "polars-ops" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efdbdb4d9a92109bc2e0ce8e17af5ae8ab643bb5b7ee9d1d74f0aeffd1fbc95f" +checksum = "7b0aed7e169c81b98457641cf82b251f52239a668916c2e683abd1f38df00d58" dependencies = [ "ahash", "argminmax", - "base64", + "base64 0.22.1", "bytemuck", "chrono", "chrono-tz", @@ -2398,12 +2429,12 @@ dependencies = [ [[package]] name = "polars-parquet" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b421d2196f786fdfe162db614c8485f8308fe41575d4de634a39bbe460d1eb6a" +checksum = "c70670a9e51cac66d0e77fd20b5cc957dbcf9f2660d410633862bb72f846d5b8" dependencies = [ "ahash", - "base64", + "base64 0.22.1", "ethnum", "num-traits", "parquet-format-safe", @@ -2417,9 +2448,9 @@ dependencies = [ [[package]] name = "polars-pipe" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48700f1d5bd56a15451e581f465c09541492750360f18637b196f995470a015c" +checksum = "0a40ae1b3c74ee07e2d1f7cbf56c5d6e15969e45d9b6f0903bd2acaf783ba436" dependencies = [ "crossbeam-channel", "crossbeam-queue", @@ -2429,6 +2460,7 @@ dependencies = [ "polars-arrow", "polars-compute", "polars-core", + "polars-expr", "polars-io", "polars-ops", "polars-plan", @@ -2442,13 +2474,14 @@ dependencies = [ [[package]] name = "polars-plan" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fb8e2302e20c44defd5be8cad9c96e75face63c3a5f609aced8c4ec3b3ac97d" +checksum = "8daa3541ae7e9af311a4389bc2b21f83349c34c723cc67fa524cdefdaa172d90" dependencies = [ "ahash", "bytemuck", "chrono-tz", + "either", "hashbrown 0.14.3", "once_cell", "percent-encoding", @@ -2462,15 +2495,15 @@ dependencies = [ "recursive", "regex", "smartstring", - "strum_macros", + "strum_macros 0.26.2", "version_check", ] [[package]] name = "polars-row" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a515bdc68c2ae3702e3de70d89601f3b71ca8137e282a226dddb53ee4bacfa2e" +checksum = "deb285f2f3a65b00dd06bef16bb9f712dbb5478f941dab5cf74f9f016d382e40" dependencies = [ "bytemuck", "polars-arrow", @@ -2480,11 +2513,12 @@ dependencies = [ [[package]] name = "polars-sql" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4bb7cc1c04c3023d1953b2f1dec50515e8fd8169a5a2bf4967b3b082232db7" +checksum = "a724f699d194cb02c25124d3832f7d4d77f387f1a89ee42f6b9e88ec561d4ad9" dependencies = [ "hex", + "once_cell", "polars-arrow", "polars-core", "polars-error", @@ -2498,11 +2532,12 @@ dependencies = [ [[package]] name = "polars-time" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efc18e3ad92eec55db89d88f16c22d436559ba7030cf76f86f6ed7a754b673f1" +checksum = "87ebec238d8b6200d9f0c3ce411c8441e950bd5a7df7806b8172d06c1d5a4b97" dependencies = [ "atoi", + "bytemuck", "chrono", "chrono-tz", "now", @@ -2518,9 +2553,9 @@ dependencies = [ [[package]] name = "polars-utils" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c760b6c698cfe2fbbbd93d6cfb408db14ececfe1d92445dae2229ce1b5b21ae8" +checksum = "34e1a907c63abf71e5f21467e2e4ff748896c28196746f631c6c25512ec6102c" dependencies = [ "ahash", "bytemuck", @@ -2569,9 +2604,9 @@ dependencies = [ [[package]] name = "pyanndata" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c30551f41c9b8c2d04ad34ee5029c3db6c321a5a0297901c7bb700d3100e91f" +checksum = "157c4c82beef68e427308fc360bdcf4bfa9dd020b3f7e0c7010d2a7d3ae72d79" dependencies = [ "anndata", "anndata-hdf5", @@ -2672,9 +2707,9 @@ dependencies = [ [[package]] name = "pyo3-polars" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469bd1d378fb3a34c1b182383e84741d9e7c5451a5d29a3f9c557aac161876cd" +checksum = "8e726fef8618531b0ec1777f430a9225a909f9ffeacaad7bca7b43877fc3cd42" dependencies = [ "polars", "polars-core", @@ -2936,7 +2971,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64", + "base64 0.21.7", ] [[package]] @@ -3163,7 +3198,7 @@ dependencies = [ [[package]] name = "snapatac2-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "anndata", "anyhow", @@ -3291,6 +3326,19 @@ dependencies = [ "syn 2.0.50", ] +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.50", +] + [[package]] name = "syn" version = "1.0.109" diff --git a/snapatac2-python/Cargo.toml b/snapatac2-python/Cargo.toml index 8cc424716..54fa7afde 100644 --- a/snapatac2-python/Cargo.toml +++ b/snapatac2-python/Cargo.toml @@ -12,9 +12,9 @@ keywords = ["single-cell", "biology"] [dependencies] snapatac2-core = { path = "../snapatac2-core" } -anndata = "0.3.3" -anndata-hdf5 = "0.2" -pyanndata = "0.3.3" +anndata = "0.4.1" +anndata-hdf5 = "0.3" +pyanndata = "0.4.1" anyhow = "1.0" bed-utils = "0.4.1" flate2 = "1.0" @@ -24,14 +24,14 @@ linreg = "0.2" log = "0.4" linfa = "0.6" linfa-clustering = "0.6" -noodles = { version = "0.70", features = ["bam", "sam"] } +noodles = { version = "0.74", features = ["bam", "sam"] } numpy = "0.21.0" nalgebra-sparse = "0.9" nalgebra = "0.32" ndarray = "0.15" -polars = { version = "0.39", features = ["ndarray", "dtype-categorical"] } +polars = { version = "0.40", features = ["ndarray", "dtype-categorical"] } pyo3-log = "0.10" -pyo3-polars = "0.13" +pyo3-polars = "0.14" rand_isaac = "0.3" rand_core = "0.6" rand = "0.8" diff --git a/snapatac2-python/src/utils/anndata.rs b/snapatac2-python/src/utils/anndata.rs index 6008735f0..af1062534 100644 --- a/snapatac2-python/src/utils/anndata.rs +++ b/snapatac2-python/src/utils/anndata.rs @@ -37,11 +37,9 @@ impl<'py> AnnDataOp for PyAnnData<'py> { type X = memory::ArrayElem<'py>; type ElemCollectionRef<'a> = memory::ElemCollection<'a> where Self: 'a; type AxisArraysRef<'a> = memory::AxisArrays<'a> where Self: 'a; - fn x(&self) -> Self::X { self.0.x() } - fn set_x_from_iter(&self, iter: I) -> Result<()> where I: Iterator, @@ -49,77 +47,60 @@ impl<'py> AnnDataOp for PyAnnData<'py> { { self.0.set_x_from_iter(iter) } - fn set_x + HasShape>(&self, data: D) -> Result<()> { self.0.set_x(data) } - - /// Delete the 'X' element. fn del_x(&self) -> Result<()> { self.0.del_x() } - - /// Return the number of observations (rows). fn n_obs(&self) -> usize { self.0.n_obs() } - /// Return the number of variables (columns). fn n_vars(&self) -> usize { self.0.n_vars() } - - /// Return the names of observations. + fn set_n_obs(&self, n: usize) -> Result<()> { + self.0.set_n_obs(n) + } + fn set_n_vars(&self, n: usize) -> Result<()> { + self.0.set_n_vars(n) + } fn obs_names(&self) -> DataFrameIndex { self.0.obs_names() } - /// Return the names of variables. fn var_names(&self) -> DataFrameIndex { self.0.var_names() } - - /// Chagne the names of observations. fn set_obs_names(&self, index: DataFrameIndex) -> Result<()> { self.0.set_obs_names(index) } - /// Chagne the names of variables. fn set_var_names(&self, index: DataFrameIndex) -> Result<()> { self.0.set_var_names(index) } - fn obs_ix<'a, I: IntoIterator>(&self, names: I) -> Result> { self.0.obs_ix(names) } fn var_ix<'a, I: IntoIterator>(&self, names: I) -> Result> { self.0.var_ix(names) } - fn read_obs(&self) -> Result { self.0.read_obs() } fn read_var(&self) -> Result { self.0.read_var() } - - /// Change the observation annotations. fn set_obs(&self, obs: DataFrame) -> Result<()> { self.0.set_obs(obs) } - - /// Change the variable annotations. fn set_var(&self, var: DataFrame) -> Result<()> { self.0.set_var(var) } - - /// Delete the observation annotations. fn del_obs(&self) -> Result<()> { self.0.del_obs() } - - /// Delete the variable annotations. fn del_var(&self) -> Result<()> { self.0.del_var() } - fn uns(&self) -> Self::ElemCollectionRef<'_> { self.0.uns() } @@ -135,7 +116,6 @@ impl<'py> AnnDataOp for PyAnnData<'py> { fn varp(&self) -> Self::AxisArraysRef<'_> { self.0.varp() } - fn del_uns(&self) -> Result<()> { self.0.del_uns() } @@ -151,7 +131,6 @@ impl<'py> AnnDataOp for PyAnnData<'py> { fn del_varp(&self) -> Result<()> { self.0.del_varp() } - fn layers(&self) -> Self::AxisArraysRef<'_> { self.0.layers() }