DS Class 607, Assignment 1

Author

Troy Tournat

Published

September 3, 2026

Introduction

This dataset is from WastewaterSCAN, an organization part of the WastewaterSCAN / SCAN project, a partnership between Stanford University, Emory University, and Verily funded philanthropically through a gift to Stanford University.

They publicly monitor infectious diseases across the USA through local wastewater systems. As an epidemiologist, this information is important to our work monitoring the spread of diseases. Since the new respiratory season has officially started August 1st and there has been an increase in COVID in California according to the CDC.

Tackling the problem: Plan is to load data into Rstudio, creating a subset, data cleaning

Anticipated data challenges: Matching the correct data file format to read in correctly into R as well as cleaning date variables

Citations:

Analysis

#Not shown: Location on computer where I am grabbing the data and creating a saved location

#Install packages needed 
pacman::p_load(
  # Package Install and Management
  pacman,           # package install/load
  janitor,          #clean up data names 
  
  # Project and File Management
  readr,            # import data
  # General Data Management
  dplyr,            # data management
  tidyr,            # data management
  lubridate,        # work with dates
  zoo,              # work with dates
  tidyverse        # work with dates
)

#create date that changes when you download it 
current_date <- format(Sys.Date()-1, "%Y%m%d")

#Load data 
ww_data <- read.csv(paste0(csv_location, "WWSCAN_categories_", current_date, ".csv"), header=TRUE, stringsAsFactors = FALSE)

#looking at dataframe 
ls(ww_data)
 [1] "BA.2.LPPA24S.category"           "BA.2.LPPA24S.method"            
 [3] "BA.4.ORF1a.Del.141.143.category" "BA.4.ORF1a.Del.141.143.method"  
 [5] "C_auris.category"                "C_auris.method"                 
 [7] "Delta.156.157.category"          "Delta.156.157.method"           
 [9] "EVD68.category"                  "EVD68.level"                    
[11] "EVD68.method"                    "EVD68.trend"                    
[13] "HAdV_F.category"                 "HAdV_F.method"                  
[15] "HAV.category"                    "HAV.method"                     
[17] "HMPV_4.category"                 "HMPV_4.level"                   
[19] "HMPV_4.method"                   "HMPV_4.trend"                   
[21] "HPIV.category"                   "HPIV.method"                    
[23] "HV.69.70.Del.category"           "HV.69.70.Del.method"            
[25] "InfA_H1.category"                "InfA_H1.method"                 
[27] "InfA_H3_V2.category"             "InfA_H3_V2.method"              
[29] "InfA_H5.category"                "InfA_H5.method"                 
[31] "Influenza.A.category"            "Influenza.A.level"              
[33] "Influenza.A.method"              "Influenza.A.trend"              
[35] "Influenza.B.category"            "Influenza.B.method"             
[37] "last.sample.date"                "MeV_Roy.category"               
[39] "MeV_Roy.method"                  "MPXV_dD14.16.category"          
[41] "MPXV_dD14.16.method"             "MPXV_G2R_G.category"            
[43] "MPXV_G2R_G.method"               "MPXV_G2R_WA.category"           
[45] "MPXV_G2R_WA.method"              "N.Gene.category"                
[47] "N.Gene.level"                    "N.Gene.method"                  
[49] "N.Gene.trend"                    "NDM.category"                   
[51] "NDM.method"                      "Noro_G2.category"               
[53] "Noro_G2.level"                   "Noro_G2.method"                 
[55] "Noro_G2.trend"                   "Omicron.Del.143.145.category"   
[57] "Omicron.Del.143.145.method"      "Parvo_B19.category"             
[59] "Parvo_B19.method"                "plant"                          
[61] "Rota.category"                   "Rota.level"                     
[63] "Rota.method"                     "Rota.trend"                     
[65] "RSV.category"                    "RSV.level"                      
[67] "RSV.method"                      "RSV.trend"                      
[69] "S.Gene.category"                 "S.Gene.method"                  
[71] "site.name"                       "state"                          
[73] "TB_RD9.category"                 "TB_RD9.method"                  
[75] "us.census.region"                "WNV.category"                   
[77] "WNV.method"                      "XBB_bkpt.category"              
[79] "XBB_bkpt.method"                
#cleaning names slightly 
ww_data_clean <- ww_data %>% clean_names
head(ww_data_clean)
    state us_census_region                         plant
1 Alabama            South                  Bessemer, AL
2 Alabama            South  Cahaba River, Birmingham, AL
3 Alabama            South                Fultondale, AL
4 Alabama            South                    Pinson, AL
5 Alabama            South Village Creek, Birmingham, AL
6  Alaska             West                 Anchorage, AK
                                         site_name last_sample_date
1          Valley Creek Water Reclamation Facility       2026-08-31
2          Cahaba River Water Reclamation Facility       2026-08-31
3       Five Mile Creek Water Reclamation Facility       2026-08-31
4          Turkey Creek Water Reclamation Facility       2026-08-31
5         Village Creek Water Reclamation Facility       2026-08-31
6 John M. Asplund Water Pollution Control Facility       2026-08-27
  ba_2_lppa24s_category ba_2_lppa24s_method ba_4_orf1a_del_141_143_category
1        not calculated                none                  not calculated
2        not calculated                none                  not calculated
3        not calculated                none                  not calculated
4        not calculated                none                  not calculated
5        not calculated                none                  not calculated
6        not calculated                none                  not calculated
  ba_4_orf1a_del_141_143_method c_auris_category        c_auris_method
1                          none     not detected not commonly detected
2                          none     not detected not commonly detected
3                          none     not detected not commonly detected
4                          none     not detected not commonly detected
5                          none     not detected not commonly detected
6                          none     not detected not commonly detected
  delta_156_157_category delta_156_157_method evd68_category evd68_level
1         not calculated                 none            low            
2         not calculated                 none            low            
3         not calculated                 none            low            
4         not calculated                 none            low            
5         not calculated                 none            low            
6         not calculated                 none            low            
  evd68_method evd68_trend hav_category            hav_method h_ad_v_f_category
1     seasonal             not detected not commonly detected    not calculated
2     seasonal             not detected not commonly detected    not calculated
3     seasonal             not detected not commonly detected    not calculated
4     seasonal             not detected not commonly detected    not calculated
5     seasonal             not detected not commonly detected    not calculated
6     seasonal             not detected not commonly detected    not calculated
  h_ad_v_f_method hmpv_4_category hmpv_4_level hmpv_4_method hmpv_4_trend
1            none             low                   seasonal             
2            none             low                   seasonal             
3            none             low                   seasonal             
4            none             low                   seasonal             
5            none             low                   seasonal             
6            none             low                   seasonal             
   hpiv_category hpiv_method hv_69_70_del_category hv_69_70_del_method
1 not calculated        none        not calculated                none
2 not calculated        none        not calculated                none
3 not calculated        none        not calculated                none
4 not calculated        none        not calculated                none
5 not calculated        none        not calculated                none
6 not calculated        none        not calculated                none
  inf_a_h1_category inf_a_h1_method inf_a_h3_v2_category inf_a_h3_v2_method
1               low        seasonal                  low           seasonal
2               low        seasonal                  low           seasonal
3               low        seasonal                  low           seasonal
4               low        seasonal                  low           seasonal
5               low        seasonal                  low           seasonal
6               low        seasonal                  low           seasonal
  inf_a_h5_category       inf_a_h5_method influenza_a_category
1      not detected not commonly detected                  low
2      not detected not commonly detected                  low
3      not detected not commonly detected                  low
4      not detected not commonly detected                  low
5      not detected not commonly detected                  low
6      not detected not commonly detected                 high
  influenza_a_level          influenza_a_method    influenza_a_trend
1                                      seasonal                     
2                                      seasonal                     
3                                      seasonal                     
4                                      seasonal                     
5                                      seasonal                     
6              high seasonal: commonly detected no significant trend
  influenza_b_category influenza_b_method mpxv_g2r_g_category
1                  low           seasonal        not detected
2                  low           seasonal        not detected
3                  low           seasonal        not detected
4                  low           seasonal        not detected
5                  low           seasonal        not detected
6                  low           seasonal        not detected
      mpxv_g2r_g_method mpxv_g2r_wa_category mpxv_g2r_wa_method
1 not commonly detected       not calculated               none
2 not commonly detected       not calculated               none
3 not commonly detected       not calculated               none
4 not commonly detected       not calculated               none
5 not commonly detected       not calculated               none
6 not commonly detected       not calculated               none
  mpxv_d_d14_16_category  mpxv_d_d14_16_method me_v_roy_category
1           not detected not commonly detected      not detected
2           not detected not commonly detected      not detected
3           not detected not commonly detected      not detected
4           not detected not commonly detected      not detected
5           not detected not commonly detected      not detected
6           not detected not commonly detected      not detected
        me_v_roy_method n_gene_category n_gene_level     n_gene_method
1 not commonly detected            high         high commonly detected
2 not commonly detected            high         high commonly detected
3 not commonly detected            high         high commonly detected
4 not commonly detected            high         high commonly detected
5 not commonly detected            high       medium commonly detected
6 not commonly detected            high         high commonly detected
          n_gene_trend   ndm_category ndm_method noro_g2_category noro_g2_level
1 no significant trend not calculated       none           medium        medium
2 no significant trend not calculated       none              low           low
3 no significant trend not calculated       none              low           low
4                   up not calculated       none              low           low
5                   up not calculated       none              low           low
6 no significant trend not calculated       none              low           low
     noro_g2_method        noro_g2_trend omicron_del_143_145_category
1 commonly detected no significant trend               not calculated
2 commonly detected no significant trend               not calculated
3 commonly detected no significant trend               not calculated
4 commonly detected no significant trend               not calculated
5 commonly detected no significant trend               not calculated
6 commonly detected no significant trend               not calculated
  omicron_del_143_145_method parvo_b19_category      parvo_b19_method
1                       none       not detected not commonly detected
2                       none       not detected not commonly detected
3                       none       not detected not commonly detected
4                       none       not detected not commonly detected
5                       none       not detected not commonly detected
6                       none       not detected not commonly detected
  rsv_category rsv_level rsv_method rsv_trend rota_category rota_level
1          low             seasonal                     low        low
2          low             seasonal                  medium     medium
3          low             seasonal                     low        low
4          low             seasonal                     low        low
5          low             seasonal                  medium     medium
6          low             seasonal                  medium     medium
        rota_method           rota_trend s_gene_category s_gene_method
1 commonly detected no significant trend  not calculated          none
2 commonly detected no significant trend  not calculated          none
3 commonly detected no significant trend  not calculated          none
4 commonly detected no significant trend  not calculated          none
5 commonly detected no significant trend  not calculated          none
6 commonly detected no significant trend  not calculated          none
  tb_rd9_category tb_rd9_method wnv_category            wnv_method
1  not calculated          none not detected not commonly detected
2  not calculated          none not detected not commonly detected
3  not calculated          none not detected not commonly detected
4  not calculated          none not detected not commonly detected
5  not calculated          none not detected not commonly detected
6  not calculated          none not detected not commonly detected
  xbb_bkpt_category xbb_bkpt_method
1    not calculated            none
2    not calculated            none
3    not calculated            none
4    not calculated            none
5    not calculated            none
6    not calculated            none
#subset to West in California for respiratory disease (Influenza, RSV, SARS-CoV-2, Human Metapneumovirus, EVD68, Parainfluenza,Parvovirus) in the last year. Also renaming variables for dif diseases 
ww_data_subset <- ww_data_clean %>%
  select(state, plant, site_name, last_sample_date, 
         inf_a_h1_category, inf_a_h3_v2_category, inf_a_h5_category, influenza_a_category, influenza_b_category, 
         rsv_category, n_gene_category, hmpv_4_category, evd68_category, hpiv_category, parvo_b19_category)%>% 
  filter(state == "California", last_sample_date > 2025)%>% 
  rename(
      flu_a_h1 = inf_a_h1_category, 
      flu_a_h3 = inf_a_h3_v2_category, 
      flu_a_h5 = inf_a_h5_category, 
      flu_a = influenza_a_category, 
      flu_b = influenza_b_category, 
      rsv = rsv_category, 
      sars_cov_2 = n_gene_category, 
      human_metapneumovirus = hmpv_4_category, 
      evd68 = evd68_category, 
      parainfluenz = hpiv_category, 
      parovirus = parvo_b19_category
  )

head(ww_data_subset)
       state                  plant
1 California              Davis, CA
2 California            Fremont, CA
3 California             Gilroy, CA
4 California              Indio, CA
5 California             Lompoc, CA
6 California Los Angeles County, CA
                                          site_name last_sample_date flu_a_h1
1          City of Davis Wastewater Treatment Plant       2026-08-31      low
2 [Fremont Basin] -  Raymond A. Boege Alvarado WWTP       2026-08-27      low
3        South County Regional Wastewater Authority       2026-09-01      low
4                          Valley Sanitary District       2026-08-31      low
5      Lompoc Regional Wastewater Reclamation Plant       2026-08-31      low
6               A.K. Warren Water Resource Facility       2026-08-30      low
  flu_a_h3     flu_a_h5 flu_a flu_b rsv sars_cov_2 human_metapneumovirus evd68
1      low not detected   low   low low       high                   low   low
2      low not detected   low   low low       high                   low   low
3      low not detected   low   low low       high                   low   low
4      low not detected   low   low low        low                   low  high
5      low not detected   low   low low       high                   low   low
6      low not detected   low   low low       high                   low   low
    parainfluenz    parovirus
1 not calculated not detected
2 not calculated       medium
3 not calculated          low
4 not calculated not detected
5 not calculated not detected
6 not calculated          low

Conclusion

Now that the data is ingested and cleaned, it would be interesting to compare this data source with the CDC’s wastewater data. Also it would be interesting to visualize the information through data table summaries and graphs over time.