cohort
#order the plot data
t<- cartar%>% arrange(Cohort, desc(tos)) %>% mutate(row = row_number())
t$num <- 1:nrow(t)
p11 <- ggplot(t, aes(x=reorder(Subject_ID,-num), y=tos, fill=Cohort)) +
geom_bar(stat="identity", position=position_dodge(0.7), width=0.4)+
scale_fill_brewer(palette = "Pastel1") +
coord_flip()+
geom_point(data=carta3, aes(Subject_ID, dosem)) +
labs(fill="Cohort", colour="", x="Dummy ID",
y="Months") +
theme_minimal() + theme(legend.position="right", legend.justification=c(0,1))+
#theme(legend.justification = "left")+
guides(fill=guide_legend("Cohort"))
p11

#Extract Label
ggp_l1_s1<-get_legend(p11)
Ongoing
o <- filter (t, cont=="Y")
p12 <- p11+
geom_point(data=o, aes(Subject_ID, tos1, shape=`Relapse.or.Censoring`), size=5)+
scale_shape_manual(values=c( "\u2192"))+labs(shape="Ongoing") +
guides(fill="none" )+
theme(legend.position="right", legend.justification=c(0,1),
legend.title=element_blank()) #Remove legend Label
# theme(legend.justification = "right")
p12

#Extract Label
ggp_l1_s2<-get_legend(p12)
Response
t1 <- ggplot(t, aes(x=reorder(Subject_ID,-num), y=tos, fill=Cohort)) +
geom_bar(stat="identity", position=position_dodge(0.7), width=0.35)+
coord_flip()+
scale_fill_brewer(palette = "Pastel1") +
geom_point(data=carta3, aes(Subject_ID, rm, color=factor(Response)), shape=18, size=5) +
labs(fill="Cohort", colour="Response", x="Dummy ID",
y="Months") +
theme_bw() + guides(fill="none")+
scale_color_manual( breaks = c("Complete Response", "Partial Response", "Stable Disease", "Progressive Disease"),
values = c('#4c8045', '#e9cb95', '#1e59d0','#e3716e'),
labels = c("Complete Response", "Partial Response", "Stable Disease", "Progressive Disease"))+
theme(panel.grid.minor=element_blank(),
panel.grid.major=element_blank()) + theme(legend.position="right", legend.justification=c(0,1))
#theme(legend.justification = "left")
t1

ggp_l1_s3<-get_legend(t1)
Main graph
n1 <- ggplot(t, aes(x= reorder(Subject_ID, -num), y=tos, fill=Cohort)) +
geom_bar(stat="identity", position=position_dodge(0.7), width=0.5)+ scale_fill_brewer(palette = "Pastel1") +
coord_flip()+
geom_point(data=carta3, aes(Subject_ID, rm, color=factor(Response)), shape=18, size=5) +
geom_point(data=carta3, aes(Subject_ID, dosem), shape=16)+
labs(fill="Cohort", colour="Response", x="Dummy ID",
y="Months") +
scale_y_continuous(breaks=c(0,2,4,6,8,10))+
theme_bw() + theme(legend.position = "none")+
scale_color_manual( breaks = c("Complete Response", "Partial Response", "Stable Disease", "Progressive Disease"),
values = c('#4c8045', '#e9cb95', '#1e59d0','#e3716e'),
labels = c("Complete Response", "Partial Response", "Stable Disease", "Progressive Disease"))+
theme(panel.grid.minor=element_blank(),
panel.grid.major=element_blank())
colnames(t)[37]<- "Relapse/Censoring"
n12 <- n1+geom_point(data=o,
aes(Subject_ID, tos1, shape=`Relapse.or.Censoring`),size=6)+
scale_shape_manual(values=c( "\u2192"))+
labs(caption="Note: This is a dummy data sample of a Swimmer plot .
")+
theme(plot.caption = element_text(hjust = 0,size=8))
n12
