anndata icon indicating copy to clipboard operation
anndata copied to clipboard

X and var not available

Open weshorton opened this issue 6 months ago • 0 comments

Unable to access X or var in the object.

Download pbmc_1k_protein_v3_processed.h5ad from here into ~/Downloads folder.

Example in R

library(anndata)
test_data <- read_h5ad("~/Downloads/pbmc_1k_protein_v3_processed.h5ad")
test_data

Screenshot 2024-08-09 at 11 58 05 AM

names_v <- names(test_data)
names_v

Screenshot 2024-08-09 at 11 58 32 AM

Test all object elements except the two problem ones:

objs_ls <- list()
badNames_v <- c("var", "X")
for (i in 1:length(names_v)) {
  
  currName_v <- names_v[i]
  cat(currName_v, "\n")
  if (currName_v %in% badNames_v) next
  
  objs_ls[[currName_v]] <- test_data[[currName_v]]
  
}

Test var:

test_data$var

Screenshot 2024-08-09 at 12 00 39 PM Test X:

test_data$X

Screenshot 2024-08-09 at 12 01 23 PM

Example in Python

import anndata as ad
test_path = "/Users/hortowe/Downloads/pbmc_1k_protein_v3_processed.h5ad"
test_data = ad.read_h5ad(test_path)
print(test_data)

Screenshot 2024-08-09 at 12 06 12 PM

print(test_data.var)

Screenshot 2024-08-09 at 12 07 13 PM

print(test_data.X)

Screenshot 2024-08-09 at 12 06 42 PM

weshorton avatar Aug 09 '24 19:08 weshorton