Skip to content

Commit

Permalink
port rownames-related changes from #166 and #169
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Jul 4, 2024
1 parent 52fc4f0 commit 6980a18
Show file tree
Hide file tree
Showing 33 changed files with 399 additions and 540 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ Config/Needs/website: pkgdown, tibble, knitr, rprojroot, stringr, readr,
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE, r6 = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
biocViews: SingleCell, DataImport, DataRepresentation
7 changes: 0 additions & 7 deletions R/AbstractAnnData.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,6 @@ AbstractAnnData <- R6::R6Class("AbstractAnnData", # nolint
))
}

if (has_row_names(df)) {
warning(wrap_message(
"'", label, "' should not have any rownames, removing them from the data frame."
))
rownames(df) <- NULL
}

df
},

Expand Down
24 changes: 8 additions & 16 deletions R/AnnData.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
#'
#' To read an AnnData file from disk, use [read_h5ad()] instead.
#'
#' @param obs_names A vector of unique identifiers
#' used to identify each row of `obs` and to act as an index into the
#' observation dimension of the AnnData object. The length of `obs_names`
#' defines the observation dimension of the AnnData object.
#' @param var_names A vector of unique identifiers used to identify each row
#' of `var` and to act as an index into the variable dimension of the
#' AnnData object. The length of `var_names` defines the variable
#' dimension of the AnnData object.
#' @param X Either `NULL` or a observation × variable matrix with
#' dimensions consistent with `obs` and `var`.
#' @param layers Either `NULL` or a named list, where each element is an
Expand All @@ -41,27 +33,27 @@
#' element is a sparse matrix where each dimension has length `n_vars`.
#' @param uns The uns slot is used to store unstructured annotation. It must
#' be either `NULL` or a named list.
#' @param shape Shape tuple (#observations, #variables). Can only be provided
#' if `X` is `None`.
#'
#' @export
#'
#' @examples
#' adata <- AnnData(
#' obs_names = paste0("obs", 1:3),
#' var_names = paste0("var", 1:4),
#' X = matrix(1:12, nrow = 3, ncol = 4),
#' obs = data.frame(
#' row.names = paste0("obs", 1:3),
#' n_counts = c(1, 2, 3),
#' n_cells = c(1, 2, 3)
#' ),
#' var = data.frame(
#' row.names = paste0()
#' n_cells = c(1, 2, 3, 4)
#' )
#' )
#'
#' adata
AnnData <- function(
obs_names = NULL,
var_names = NULL,
X = NULL,
obs = NULL,
var = NULL,
Expand All @@ -70,10 +62,9 @@ AnnData <- function(
varm = NULL,
obsp = NULL,
varp = NULL,
uns = NULL) {
uns = NULL,
shape = shape) {
InMemoryAnnData$new(
obs_names = obs_names,
var_names = var_names,
X = X,
obs = obs,
var = var,
Expand All @@ -82,6 +73,7 @@ AnnData <- function(
varm = varm,
obsp = obsp,
varp = varp,
uns = uns
uns = uns,
shape = shape
)
}
Loading

0 comments on commit 6980a18

Please sign in to comment.