You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not very familiar with Anndata objects so I don't know if this is a common problem, but the one I was working with had missing observable values labeled with -1. Because the LoadH5ADobs tried to convert the column to a factor but is missing a label for these -1 values, the function can throw this error:
Error in factor(x = obs_value_i, labels = hfile_cate[[obs.i]][]) :
invalid 'labels'; length 24 should be 1 or 25
Which says that I have 24 labels for the 25 values with an extra -1 value.
My simple fix for this was checking if the number of unique values obs_value_i matches the length of the labels. Obviously this will fail if there is more than one missing value or if it's not -1.
if ('__categories'%in% names(x=hfile_obs)) {
hfile_cate<-hfile_obs[['__categories']]
for (iin seq_along(obs_groups)) {
obs.i<-obs_groups[i]
obs_value_i<-hfile_obs[[obs.i]][]
if (obs.i%in% names(x=hfile_cate)){
# If the observable has missing values, they're labeled as -1.# Then you add to add -1 to the categoriesif (length(unique(obs_value_i)) == length(hfile_cate[[obs.i]][])){
obs_value_i<-factor(x=obs_value_i, labels=hfile_cate[[obs.i]][])
}else{
labels= c('-1', hfile_cate[[obs.i]][])
obs_value_i<-factor(x=obs_value_i, labels=labels)
}
}
matrix[,i] <-obs_value_i
}
}
The text was updated successfully, but these errors were encountered:
Hi,
I'm not very familiar with Anndata objects so I don't know if this is a common problem, but the one I was working with had missing observable values labeled with -1. Because the LoadH5ADobs tried to convert the column to a factor but is missing a label for these -1 values, the function can throw this error:
Error in factor(x = obs_value_i, labels = hfile_cate[[obs.i]][]) :
invalid 'labels'; length 24 should be 1 or 25
Which says that I have 24 labels for the 25 values with an extra -1 value.
My simple fix for this was checking if the number of unique values obs_value_i matches the length of the labels. Obviously this will fail if there is more than one missing value or if it's not -1.
The text was updated successfully, but these errors were encountered: