Preliminary analysis into the epidemiology of mastiits in coastal NSW dairy herds
This preliminary analysis explores the burden of mastitis in NSW dairy herds, drawing on farm records and milk quality data. The objectives are to quantify the frequency and distribution of clinical mastitis and somatic cell count outcomes, identify seasonal and herd-level patterns, and highlight where mastitis incidence exceeds accepted benchmarks. By providing an evidence-based overview of the problem, the analysis aims to inform future research directions, support farmer decision-making, and establish a foundation for evaluating targeted strategies to improve milk quality, cow longevity, and overall herd health in NSW dairy systems.
Season pattern of bulk milk somatic cell counts for herd health clients in NSW combined. Each dot represents a milk pick-up for a herd. Somatic cell counts increase over summer, with some herds seeing values more than 400,000 cells/ml.
demo_mast_herd <- demo_multi_herd_df %>%filter(herd_name %in% mast_herds) %>%select(nationalid,calving_date,mast,mast_2,mast_3,mast_tar,mast_2_tar,mast_3_tar,first_mast,mast_2_date,mast_3_date,dry_off_date,removal_date,end_date,quarter_start,herd_name) %>%left_join(mast_recording_window, by ="herd_name") %>%mutate(year =year(calving_date),year_cat =case_when( year <=2015~"2015 or earlier", year %>%between(2016,2020) ~"2016 to 2020", year %>%between(2021,2025) ~"2021 to 2025" ),follow_up_within_windows =case_when( calving_date %>%between(mast_first_record_herd,mast_last_record_herd) & end_date %>%between(mast_first_record_herd,mast_last_record_herd) ~1, T ~0) )#demo_mast_herd %>% tabyl(follow_up_within_windows)demo_mast_herd <- demo_mast_herd %>%filter(follow_up_within_windows ==1)demo_mast <-rbind( demo_mast_herd %>%select(nationalid,mast,mast_tar,quarter_start) %>%mutate(case ="Cows with at least 1 clinical case"), demo_mast_herd %>%mutate(mast = mast_2,mast_tar = mast_2_tar,case ="Cows with at least 2 clinical cases") %>%select(nationalid,mast,mast_tar,quarter_start,case), demo_mast_herd %>%mutate(mast = mast_3,mast_tar = mast_3_tar,case ="Cows with at least 3 clinical cases") %>%select(nationalid,mast,mast_tar,quarter_start,case))KM <-survfit(Surv(mast_tar, mast) ~ case, data = demo_mast)KM_data <-surv_summary(KM,demo_mast_herd) %>%filter(n.risk >2)max_y <-pmax(0.5,KM_data %>%summarise(max_y =1-min(surv)))ggsurvplot_df(KM_data,ylim =c(0, max_y),title ="",ylab ="Percent of cows",legend =c(0.25, 0.75),legend.title="",legend.labs =c("Cows with at least 1 clinical case","Cows with at least 2 clinical cases","Cows with at least 3 clinical cases"),#linetype = c(3,2,1),linetype =1,palette =c("blue","orange","red"),xlim =c(0, 300),pval = F, censor=F, conf.int = F,risk.table = F, surv.plot.height =5, risk.table.pos="in", fun ="event",surv.scale="percent", break.x.by =20,break.y.by =0.05, ggtheme =theme_bw(base_family ="Times New Roman"),xlab="Days in milk",risk.table.fontsize=3)
Proportion of cows with at least 1, 2, or 3 cases of mastitis by days in milk.
Show the code
KM <-survfit(Surv(mast_tar, mast) ~ year_cat, data = demo_mast_herd)KM_data <-surv_summary(KM,demo_mast) %>%filter(n.risk >2)max_y <-pmax(0.5,KM_data %>%summarise(max_y =1-min(surv)))ggsurvplot_df(KM_data,ylim =c(0, max_y),title =paste0("Lactations (n = ",max(KM_data$n.risk),")"),ylab ="Percent of cows",legend =c(0.25, 0.75),legend.title="",linetype =1,xlim =c(0, 300),pval = F, censor=F, conf.int = F,risk.table = F, surv.plot.height =5, risk.table.pos="in", fun ="event",surv.scale="percent", break.x.by =20,break.y.by =0.05, ggtheme =theme_bw(base_family ="Times New Roman"),xlab="Days in milk",risk.table.fontsize=3) +geom_vline(xintercept =14, linetype="dashed", color ="blue", linewidth=0.5)
Proportion of cows with at least 1 case of mastitis by days in milk, stratified by year of calving group.
Show the code
KM <-survfit(Surv(mast_tar, mast) ~ herd_name, data = demo_mast_herd)KM_data <-surv_summary(KM,demo_mast) %>%filter(n.risk >2)max_y <-pmax(0.5,KM_data %>%summarise(max_y =1-min(surv)))ggsurvplot_df(KM_data,ylim =c(0, max_y),title =paste0("Mastitis rates from 1-300 DIM. Each line is a herd"),ylab ="Percent of cows",legend ="none",linetype =1,xlim =c(0, 300),pval = F, censor=F, conf.int = F,risk.table = F, surv.plot.height =5, risk.table.pos="in", fun ="event",surv.scale="percent", break.x.by =20,break.y.by =0.05, ggtheme =theme_bw(base_family ="Times New Roman"),xlab="Days in milk",risk.table.fontsize=3) +geom_vline(xintercept =14, linetype="dashed", color ="blue", linewidth=0.5)