knitr::opts_chunk$set(echo = FALSE, Warning = FALSE, message = FALSE)
Emma B. Hodcroft. 2021. "CoVariants: SARS-CoV-2 Mutations and Variants of Interest." https://covariants.org/
This data is from https://github.com/hodcroftlab/covariants/tree/master. It reports the proportion of cases that are each variant every 2 weeks for the state of Wisconsin. Below there are 2 methods the first shows the proportion of each variant all together and the second shows only variants that are over 50% (i.e. the dominant variants)
library(Covid19Wastewater) library(data.table) library(dplyr) library(ggplot2) library(tidyr) data(Covariants_data, package = "Covid19Wastewater") Covariants_data$category <- row.names(Covariants_data) onlycovar <- Covariants_data[-c(1,2)] mdfr <- pivot_longer(onlycovar, cols = -category, names_to = 'variable', values_to = 'value') #melt(onlycovar, id.vars = "category")
To see more about each variant look here https://covariants.org/. Category refers to the 2 week time period when the data was collected, total_sequences is the total of all variants for that time period, week is the start of the 2-week time period.
Covariants_data%>% select(week:X20J..Gamma..V3.)%>% head()%>% knitr::kable()
percentages <- mdfr %>% group_by(category) %>% mutate(sum = sum(value), percent = value/sum, majority = case_when(percent > .5 ~ paste(variable))) per <- percentages %>% drop_na(majority) dates <- Covariants_data[c("week","category")] perDates <- merge(per,dates,by="category")
VariantPercentage <- mdfr%>% ggplot(aes(factor(category, levels = c(1:69)), value, fill = variable)) + geom_bar(position = "fill", stat = "identity") + labs(x = "bi-weekly (2020-08-17 to 2022-12-05)", y = "Covariant Percent", title = "All variants by percentage of cases reported")+ theme(legend.position="bottom", axis.text.x = element_text(angle = 90, hjust=1)) VariantPercentage #Run this for interactive graph #ggplotly(VariantPercentage)
ggplot(perDates, aes(x=week, y=percent,fill=majority)) + geom_col() + theme(axis.text.x = element_text(angle = 90, hjust=1)) + labs(x = "bi-weekly (2020-08-17 to 2022-12-05)", y = "Percent of total cases", title = "Variants over 50% of reported cases")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.