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
Objective
Hello,
I have used a code to generate ComplexUpset graphics that works on my PC. I also work in a secure bubble (CAS-D), I tried to import and reproduce the same analysis in the bubble but I get an error even though the format of my data is exactly the same.
I've checked the package updates but it still doesn't work and I don't understand the error, as the format of my data is the same as on my usual PC.
This is the error I get:
Error in 'vec_slice()' :
! Can't subset elements with 'i'.
Subscript 'i' must be a simple vector, not a matrix.
Run 'rlang::last_trace()' to see where the error occurred.
Thank you in advance for your help.
Code
set_size=function(w, h, factor=1.5) {
s=1*factor
options(
repr.plot.width=w*s,
repr.plot.height=h*s,
repr.plot.res=100/factor,
jupyter.plot_mimetypes='image/png',
jupyter.plot_scale=1
)
}
set_size(8, 3)
size<- get_size_mode('exclusive_intersection')
expos<- c("BorgVenn",
"C_AQ_EXPOACT_Trrepet_01",
"C_AQ_EXPOACT_TrOutVibr_01",
"C_AQ_EXPOACT_TrTordPoignet_01",
"C_AQ_EXPOACT_TrPincer_01")
BDD_finale_CC_UpsetBiomeca_hommes[expos] <-BDD_finale_CC_UpsetBiomeca_hommes[expos] ==1|BDD_finale_CC_UpsetBiomeca_hommes[expos] =="Oui"# Copiez le dataframe pour éviter de modifier l'originalBDD_finale_CC_UpsetBiomeca_hommes_mod<-BDD_finale_CC_UpsetBiomeca_hommes# Renommez les colonnes pour l'affichage
colnames(BDD_finale_CC_UpsetBiomeca_hommes_mod)[colnames(BDD_finale_CC_UpsetBiomeca_hommes_mod) %in%expos] <- c(
"Repetitive hand movements",
"Hand-transmitted vibrations",
"Awkward wrist postures",
"Repetitive pinching",
"High physical perceived exertion (RPE ≥12)")
expos<- c("High physical perceived exertion (RPE ≥12)",
"Repetitive hand movements",
"Hand-transmitted vibrations",
"Awkward wrist postures",
"Repetitive pinching")
# Fonction pour calculer les tailles et les pourcentages des intersectionscalculate_intersection_sizes<-function(data, sets) {
upset_data<-data %>%
dplyr::select(all_of(sets)) %>%
mutate(across(everything(), as.logical)) %>%
group_by(across(everything())) %>%
summarise(size= n(), .groups='drop') %>%
ungroup()
total_size<- sum(upset_data$size)
upset_data<-upset_data %>%
mutate(percentage=size/total_size*100) %>%
mutate(text_label= paste0(round(percentage, 1), "%\n(", size, ")"))
return(upset_data)
}
# Calculez les tailles et les pourcentages des intersectionsintersection_sizes<- calculate_intersection_sizes(BDD_finale_CC_UpsetBiomeca_hommes_mod, expos)
# Vérifiez que les pourcentages sont calculés correctement
print(intersection_sizes)
# Fonction pour générer les labels d'annotationsgenerate_labels<-function(size, data) {
match_indices<- match(size, data$size)
return(data$text_label[match_indices])
}
# Graphique avec ComplexUpsetupset_plot<-ComplexUpset::upset(
BDD_finale_CC_UpsetBiomeca_hommes_mod,
expos,
name='Exposure',
width_ratio=0.1,
min_size=30,
min_degree=1,
base_annotations=list(
'Intersection size'= intersection_size(
text_mapping= aes(
label= generate_labels(!!size, intersection_sizes),
colour= ifelse(!!size>300, 'on_bar', 'on_background'),
y= ifelse(!!size>300, !!size-300, !!size)
)
)
),
set_sizes= (
upset_set_size()
+ geom_text(aes(label=..count..), hjust=0, stat='count', color='white')
+ theme(axis.text.x= element_text(angle=90),
axis.ticks.x= element_line())
)
)
# Affichez le graphique
print(upset_plot)
Objective
Hello,
I have used a code to generate ComplexUpset graphics that works on my PC. I also work in a secure bubble (CAS-D), I tried to import and reproduce the same analysis in the bubble but I get an error even though the format of my data is exactly the same.
I've checked the package updates but it still doesn't work and I don't understand the error, as the format of my data is the same as on my usual PC.
This is the error I get:
Error in 'vec_slice()' :
! Can't subset elements with 'i'.
Subscript 'i' must be a simple vector, not a matrix.
Run 'rlang::last_trace()' to see where the error occurred.
Thank you in advance for your help.
Code
Context (required)
ComplexUpset version: 1.3.3
R version details
R session information
The text was updated successfully, but these errors were encountered: