install.packages("readxl")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
library("readxl")
data = read_xlsx("survival data collection template .xlsx")
## Warning: Expecting numeric in G3 / R3C7: got a date
## Warning: Expecting numeric in H3 / R3C8: got a date
## Warning: Expecting numeric in I3 / R3C9: got a date
## Warning: Expecting numeric in J3 / R3C10: got a date
## Warning: Expecting numeric in K3 / R3C11: got a date
## Warning: Expecting numeric in L3 / R3C12: got a date
## Warning: Expecting numeric in M3 / R3C13: got a date
## Warning: Expecting numeric in N3 / R3C14: got a date
## Warning: Expecting numeric in O3 / R3C15: got a date
## Warning: Expecting numeric in P3 / R3C16: got a date
## Warning: Expecting numeric in Q3 / R3C17: got a date
## Warning: Expecting numeric in R3 / R3C18: got a date
## Warning: Expecting numeric in T3 / R3C20: got a date
## Warning: Expecting numeric in V3 / R3C22: got a date
## Warning: Expecting numeric in G4 / R4C7: got a date
## Warning: Expecting numeric in H4 / R4C8: got a date
## Warning: Expecting numeric in I4 / R4C9: got a date
## Warning: Expecting numeric in J4 / R4C10: got a date
## Warning: Expecting numeric in K4 / R4C11: got a date
## Warning: Expecting numeric in L4 / R4C12: got a date
## Warning: Expecting numeric in M4 / R4C13: got a date
## Warning: Expecting numeric in N4 / R4C14: got a date
## Warning: Expecting numeric in O4 / R4C15: got a date
## Warning: Expecting numeric in P4 / R4C16: got a date
## Warning: Expecting numeric in Q4 / R4C17: got a date
## Warning: Expecting numeric in R4 / R4C18: got a date
## Warning: Expecting numeric in T4 / R4C20: got a date
## Warning: Expecting numeric in V4 / R4C22: got a date
## New names:
## • `` -> `...3`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
## • `` -> `...16`
## • `` -> `...17`
## • `` -> `...18`
## • `` -> `...19`
## • `` -> `...20`
## • `` -> `...21`
head(data)
## # A tibble: 6 × 21
## `P.ent. OD=` `100` ...3 `Infection start:=` `04.03.2024`
## <chr> <chr> <chr> <chr> <chr>
## 1 GENOTYPE FOOD SEX INFECTION REPLICATE
## 2 <NA> <NA> <NA> <NA> <NA>
## 3 daxx[NP4778] Normal M vehicle 1
## 4 daxx[NP4778] Normal M vehicle 2
## 5 daxx[NP4778] Normal M vehicle 3
## 6 daxx[NP4778] Normal M P.ent. 1
## # ℹ 16 more variables:
## # `DATE:TIME (YYYY-MM-DD HH:MM:SS), e.g. 2024-03-05 09:00:00` <dbl>,
## # ...7 <dbl>, ...8 <dbl>, ...9 <dbl>, ...10 <dbl>, ...11 <dbl>, ...12 <dbl>,
## # ...13 <dbl>, ...14 <dbl>, ...15 <dbl>, ...16 <dbl>, ...17 <dbl>,
## # ...18 <chr>, ...19 <dbl>, ...20 <chr>, ...21 <dbl>
setwd("/home/catherinetaylor35")
# Install the packages
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
## Bioconductor version '3.16' is out-of-date; the current release version '3.18'
## is available with R version '4.3'; see https://bioconductor.org/install
BiocManager::install("phyloseq")
## 'getOption("repos")' replaces Bioconductor standard repositories, see
## 'help("repositories", package = "BiocManager")' for details.
## Replacement repositories:
## CRAN: https://cloud.r-project.org
## Bioconductor version 3.16 (BiocManager 1.30.22), R 4.2.2 Patched (2022-11-10
## r83330)
## Warning: package(s) not installed when version(s) same as or greater than current; use
## `force = TRUE` to re-install: 'phyloseq'
## Installation paths not writeable, unable to update packages
## path: /usr/lib/R/library
## packages:
## boot, class, cluster, codetools, foreign, KernSmooth, lattice, MASS,
## Matrix, mgcv, nlme, nnet, rpart, spatial, survival
## Old packages: 'bslib', 'callr', 'data.table', 'ggsci', 'htmltools', 'knitr',
## 'lme4', 'munsell', 'RcppArmadillo', 'rstudioapi', 'xfun'
install.packages("lattice")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("ggplot2")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("tidyr")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("purrr")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
installed.packages("tibble")
## Package LibPath Version Priority Depends Imports LinkingTo Suggests
## Enhances License License_is_FOSS License_restricts_use OS_type Archs
## MD5sum NeedsCompilation Built
install.packages("stringr")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("forcats")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("magrittr")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("janitor")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library("phyloseq")
library("lattice")
library("ggplot2")
library("tidyr")
library("purrr")
library("tibble")
library("stringr")
library("forcats")
library("magrittr")
##
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
##
## set_names
## The following object is masked from 'package:tidyr':
##
## extract
library(janitor)
##
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
# Inspect the data to understand its structure
# This helps to identify headers and any potential issues
print(head(data))
## # A tibble: 6 × 21
## `P.ent. OD=` `100` ...3 `Infection start:=` `04.03.2024`
## <chr> <chr> <chr> <chr> <chr>
## 1 GENOTYPE FOOD SEX INFECTION REPLICATE
## 2 <NA> <NA> <NA> <NA> <NA>
## 3 daxx[NP4778] Normal M vehicle 1
## 4 daxx[NP4778] Normal M vehicle 2
## 5 daxx[NP4778] Normal M vehicle 3
## 6 daxx[NP4778] Normal M P.ent. 1
## # ℹ 16 more variables:
## # `DATE:TIME (YYYY-MM-DD HH:MM:SS), e.g. 2024-03-05 09:00:00` <dbl>,
## # ...7 <dbl>, ...8 <dbl>, ...9 <dbl>, ...10 <dbl>, ...11 <dbl>, ...12 <dbl>,
## # ...13 <dbl>, ...14 <dbl>, ...15 <dbl>, ...16 <dbl>, ...17 <dbl>,
## # ...18 <chr>, ...19 <dbl>, ...20 <chr>, ...21 <dbl>
# Remove unnecessary rows and columns
# This step might need adjustments based on your specific data
# For example, if the first two rows are metadata and not actual data, you would remove them
data <- data[-c(1,2), ] # Adjust indices based on your data
# Rename columns to make them more descriptive
# This assumes you have columns that can be renamed for clarity
colnames(data) <- c("GENOTYPE", "FOOD", "SEX", "INFECTION", "REPLICATE") # Adjust with actual column names
install.packages("dplyr")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
# Convert factors to characters
data <- data.frame(lapply(data, function(x) if(is.factor(x)) as.character(x) else x))
# Handle missing data
# This example removes rows with any missing data - adjust based on your need
data <- na.omit(data)
print(colnames(data))
## [1] "GENOTYPE" "FOOD" "SEX" "INFECTION" "REPLICATE" "NA."
## [7] "NA..1" "NA..2" "NA..3" "NA..4" "NA..5" "NA..6"
## [13] "NA..7" "NA..8" "NA..9" "NA..10" "NA..11" "NA..12"
## [19] "NA..13" "NA..14" "NA..15"
# Convert columns with 'NA' in their name to numeric
numeric_columns <- colnames(data)[grepl("NA", colnames(data))]
data <- data %>%
mutate(across(all_of(numeric_columns), ~as.numeric(as.character(.))))
# Now 'data' has the columns converted to numeric types where the column name included "NA"
# Inspect the cleaned data
print(data)
## GENOTYPE FOOD SEX INFECTION REPLICATE NA. NA..1 NA..2 NA..3 NA..4
## 1 daxx[NP4778] Normal M vehicle 1 0 0 0 0 0
## 2 daxx[NP4778] Normal M vehicle 2 0 0 0 1 1
## 3 daxx[NP4778] Normal M vehicle 3 0 0 0 0 0
## 4 daxx[NP4778] Normal M P.ent. 1 0 2 2 2 3
## 5 daxx[NP4778] Normal M P.ent. 2 0 1 3 3 3
## 6 daxx[NP4778] Normal M P.ent. 3 0 1 2 2 3
## 7 daxx[NP4778] Normal F vehicle 1 0 0 0 0 0
## 8 daxx[NP4778] Normal F vehicle 2 0 0 0 0 0
## 9 daxx[NP4778] Normal F vehicle 3 0 2 2 2 2
## 10 daxx[NP4778] Normal F P.ent. 1 0 1 1 1 1
## 11 daxx[NP4778] Normal F P.ent. 2 0 1 1 1 1
## 12 daxx[NP4778] Normal F P.ent. 3 0 2 2 3 3
## 13 daxx[NP4778] HCr 50mM M vehicle 1 0 0 0 0 0
## 14 daxx[NP4778] HCr 50mM M vehicle 2 0 0 0 0 0
## 15 daxx[NP4778] HCr 50mM M vehicle 3 0 0 0 0 0
## 16 daxx[NP4778] HCr 50mM M P.ent. 1 0 0 1 1 2
## 17 daxx[NP4778] HCr 50mM M P.ent. 2 0 0 1 1 1
## 18 daxx[NP4778] HCr 50mM M P.ent. 3 0 0 0 0 0
## 19 daxx[NP4778] HCr 50mM F vehicle 1 0 1 1 1 1
## 20 daxx[NP4778] HCr 50mM F vehicle 2 0 1 2 2 3
## 21 daxx[NP4778] HCr 50mM F vehicle 3 0 1 2 3 3
## 22 daxx[NP4778] HCr 50mM F P.ent. 1 0 2 6 6 6
## 23 daxx[NP4778] HCr 50mM F P.ent. 2 0 5 6 6 6
## 24 daxx[NP4778] HCr 50mM F P.ent. 3 0 1 1 1 2
## 25 Dahomey Normal M vehicle 1 0 1 1 1 1
## 26 Dahomey Normal M vehicle 2 0 0 0 0 0
## 27 Dahomey Normal M vehicle 3 0 0 0 0 0
## 28 Dahomey Normal M P.ent. 1 0 0 0 0 1
## 29 Dahomey Normal M P.ent. 2 0 0 0 0 0
## 30 Dahomey Normal M P.ent. 3 0 1 1 1 1
## 31 Dahomey Normal F vehicle 1 0 0 0 0 0
## 32 Dahomey Normal F vehicle 2 0 0 0 0 0
## 33 Dahomey Normal F vehicle 3 0 0 0 0 0
## 34 Dahomey Normal F P.ent. 1 0 0 0 0 0
## 35 Dahomey Normal F P.ent. 2 0 0 0 0 0
## 36 Dahomey Normal F P.ent. 3 0 0 0 0 0
## 37 Dahomey HCr 50mM M vehicle 1 0 0 0 0 0
## 38 Dahomey HCr 50mM M vehicle 2 0 1 1 1 1
## 39 Dahomey HCr 50mM M vehicle 3 0 0 0 0 0
## 40 Dahomey HCr 50mM M P.ent. 1 0 0 0 0 0
## 41 Dahomey HCr 50mM M P.ent. 2 0 0 0 0 0
## 42 Dahomey HCr 50mM M P.ent. 3 0 0 1 2 2
## 43 Dahomey HCr 50mM F vehicle 1 0 0 0 0 0
## 44 Dahomey HCr 50mM F vehicle 2 0 0 0 0 0
## 45 Dahomey HCr 50mM F vehicle 3 0 0 0 0 0
## 46 Dahomey HCr 50mM F P.ent. 1 0 0 0 0 0
## 47 Dahomey HCr 50mM F P.ent. 2 0 0 0 0 0
## 48 Dahomey HCr 50mM F P.ent. 3 0 0 0 0 0
## NA..5 NA..6 NA..7 NA..8 NA..9 NA..10 NA..11 NA..12 NA..13 NA..14 NA..15
## 1 0 0 0 0 0 0 0 0 0 0 0
## 2 1 1 1 1 1 1 1 1 1 1 1
## 3 0 0 0 0 0 0 0 0 0 0 0
## 4 3 3 3 3 3 3 3 3 3 3 3
## 5 3 3 4 4 4 5 5 5 5 5 5
## 6 4 4 4 4 4 4 4 4 4 4 5
## 7 0 0 0 0 0 0 0 0 0 0 0
## 8 0 0 0 0 0 0 0 0 0 0 1
## 9 2 2 2 2 2 2 2 2 2 16 16
## 10 1 1 1 1 1 1 1 1 1 1 1
## 11 1 1 1 1 1 1 1 2 2 2 18
## 12 3 3 3 3 3 3 3 3 3 17 17
## 13 0 0 0 0 0 0 0 0 0 0 0
## 14 0 0 0 0 0 0 0 0 0 0 0
## 15 0 0 0 0 0 0 0 0 0 0 0
## 16 2 1 1 1 1 1 1 1 1 1 1
## 17 1 1 1 1 1 1 1 1 1 1 1
## 18 0 0 0 0 1 1 1 1 1 1 1
## 19 1 1 2 2 2 2 2 2 2 19 20
## 20 4 4 4 4 4 4 4 4 4 4 4
## 21 3 4 4 4 4 4 4 4 5 5 5
## 22 6 6 6 6 6 6 6 6 6 6 7
## 23 6 6 6 6 6 7 7 7 6 6 7
## 24 2 2 2 2 2 2 2 2 2 2 4
## 25 1 1 1 1 0 0 0 0 0 0 0
## 26 0 0 0 0 0 0 0 0 0 0 0
## 27 0 0 1 1 1 1 1 1 1 1 1
## 28 1 1 1 1 1 1 1 1 1 1 1
## 29 0 0 0 0 0 0 0 0 0 0 0
## 30 1 0 1 1 1 1 1 1 1 2 3
## 31 0 0 0 0 0 0 0 0 0 0 0
## 32 0 0 0 0 0 0 0 0 0 0 1
## 33 0 0 0 0 0 2 2 3 8 9 9
## 34 0 0 0 0 0 0 0 0 0 0 0
## 35 0 0 0 0 0 0 0 0 0 0 0
## 36 0 0 0 0 0 0 0 0 0 0 5
## 37 0 0 0 0 0 0 0 0 0 0 0
## 38 1 1 1 1 1 1 1 2 2 2 2
## 39 0 0 0 0 0 0 0 0 0 0 0
## 40 0 0 0 0 0 0 0 0 0 0 0
## 41 0 0 0 0 0 0 0 0 0 0 0
## 42 2 2 2 3 3 3 3 3 3 4 4
## 43 0 0 0 0 0 0 0 0 0 0 0
## 44 0 0 0 0 0 0 0 0 1 1 1
## 45 0 0 0 0 0 0 0 0 0 0 0
## 46 0 0 0 0 0 0 0 0 0 0 0
## 47 0 0 0 0 0 0 0 0 0 0 0
## 48 0 0 0 0 0 0 0 0 0 0 5
# Save the cleaned data
write.csv(data, "cleaned_data.csv", row.names = FALSE)
# Assuming your dataframe is named df
# Set the new column names
new_column_names <- c("GENOTYPE", "FOOD", "SEX", "INFECTION", "REPLICATE",
"2024-03-04 19:15:00", "2024-03-05 09:30:00", "2024-03-05 13:20:00",
"2024-03-05 17:40:00", "2024-03-06 09:10:00", "2024-03-06 13:05:00",
"2024-03-06 16:59:00", "2024-03-07 10:07:00", "2024-03-07 13:00:00",
"2024-03-07 17:00:00", "2024-03-08 09:00:00", "2024-03-08 13:07:00",
"2024-03-08 17:00:00", "2024-03-09 10:05:00", "2024-03-11 13:00:00",
"2024-03-12 12:40:00")
# Rename the columns
colnames(data) <- new_column_names
print(data)
## GENOTYPE FOOD SEX INFECTION REPLICATE 2024-03-04 19:15:00
## 1 daxx[NP4778] Normal M vehicle 1 0
## 2 daxx[NP4778] Normal M vehicle 2 0
## 3 daxx[NP4778] Normal M vehicle 3 0
## 4 daxx[NP4778] Normal M P.ent. 1 0
## 5 daxx[NP4778] Normal M P.ent. 2 0
## 6 daxx[NP4778] Normal M P.ent. 3 0
## 7 daxx[NP4778] Normal F vehicle 1 0
## 8 daxx[NP4778] Normal F vehicle 2 0
## 9 daxx[NP4778] Normal F vehicle 3 0
## 10 daxx[NP4778] Normal F P.ent. 1 0
## 11 daxx[NP4778] Normal F P.ent. 2 0
## 12 daxx[NP4778] Normal F P.ent. 3 0
## 13 daxx[NP4778] HCr 50mM M vehicle 1 0
## 14 daxx[NP4778] HCr 50mM M vehicle 2 0
## 15 daxx[NP4778] HCr 50mM M vehicle 3 0
## 16 daxx[NP4778] HCr 50mM M P.ent. 1 0
## 17 daxx[NP4778] HCr 50mM M P.ent. 2 0
## 18 daxx[NP4778] HCr 50mM M P.ent. 3 0
## 19 daxx[NP4778] HCr 50mM F vehicle 1 0
## 20 daxx[NP4778] HCr 50mM F vehicle 2 0
## 21 daxx[NP4778] HCr 50mM F vehicle 3 0
## 22 daxx[NP4778] HCr 50mM F P.ent. 1 0
## 23 daxx[NP4778] HCr 50mM F P.ent. 2 0
## 24 daxx[NP4778] HCr 50mM F P.ent. 3 0
## 25 Dahomey Normal M vehicle 1 0
## 26 Dahomey Normal M vehicle 2 0
## 27 Dahomey Normal M vehicle 3 0
## 28 Dahomey Normal M P.ent. 1 0
## 29 Dahomey Normal M P.ent. 2 0
## 30 Dahomey Normal M P.ent. 3 0
## 31 Dahomey Normal F vehicle 1 0
## 32 Dahomey Normal F vehicle 2 0
## 33 Dahomey Normal F vehicle 3 0
## 34 Dahomey Normal F P.ent. 1 0
## 35 Dahomey Normal F P.ent. 2 0
## 36 Dahomey Normal F P.ent. 3 0
## 37 Dahomey HCr 50mM M vehicle 1 0
## 38 Dahomey HCr 50mM M vehicle 2 0
## 39 Dahomey HCr 50mM M vehicle 3 0
## 40 Dahomey HCr 50mM M P.ent. 1 0
## 41 Dahomey HCr 50mM M P.ent. 2 0
## 42 Dahomey HCr 50mM M P.ent. 3 0
## 43 Dahomey HCr 50mM F vehicle 1 0
## 44 Dahomey HCr 50mM F vehicle 2 0
## 45 Dahomey HCr 50mM F vehicle 3 0
## 46 Dahomey HCr 50mM F P.ent. 1 0
## 47 Dahomey HCr 50mM F P.ent. 2 0
## 48 Dahomey HCr 50mM F P.ent. 3 0
## 2024-03-05 09:30:00 2024-03-05 13:20:00 2024-03-05 17:40:00
## 1 0 0 0
## 2 0 0 1
## 3 0 0 0
## 4 2 2 2
## 5 1 3 3
## 6 1 2 2
## 7 0 0 0
## 8 0 0 0
## 9 2 2 2
## 10 1 1 1
## 11 1 1 1
## 12 2 2 3
## 13 0 0 0
## 14 0 0 0
## 15 0 0 0
## 16 0 1 1
## 17 0 1 1
## 18 0 0 0
## 19 1 1 1
## 20 1 2 2
## 21 1 2 3
## 22 2 6 6
## 23 5 6 6
## 24 1 1 1
## 25 1 1 1
## 26 0 0 0
## 27 0 0 0
## 28 0 0 0
## 29 0 0 0
## 30 1 1 1
## 31 0 0 0
## 32 0 0 0
## 33 0 0 0
## 34 0 0 0
## 35 0 0 0
## 36 0 0 0
## 37 0 0 0
## 38 1 1 1
## 39 0 0 0
## 40 0 0 0
## 41 0 0 0
## 42 0 1 2
## 43 0 0 0
## 44 0 0 0
## 45 0 0 0
## 46 0 0 0
## 47 0 0 0
## 48 0 0 0
## 2024-03-06 09:10:00 2024-03-06 13:05:00 2024-03-06 16:59:00
## 1 0 0 0
## 2 1 1 1
## 3 0 0 0
## 4 3 3 3
## 5 3 3 3
## 6 3 4 4
## 7 0 0 0
## 8 0 0 0
## 9 2 2 2
## 10 1 1 1
## 11 1 1 1
## 12 3 3 3
## 13 0 0 0
## 14 0 0 0
## 15 0 0 0
## 16 2 2 1
## 17 1 1 1
## 18 0 0 0
## 19 1 1 1
## 20 3 4 4
## 21 3 3 4
## 22 6 6 6
## 23 6 6 6
## 24 2 2 2
## 25 1 1 1
## 26 0 0 0
## 27 0 0 0
## 28 1 1 1
## 29 0 0 0
## 30 1 1 0
## 31 0 0 0
## 32 0 0 0
## 33 0 0 0
## 34 0 0 0
## 35 0 0 0
## 36 0 0 0
## 37 0 0 0
## 38 1 1 1
## 39 0 0 0
## 40 0 0 0
## 41 0 0 0
## 42 2 2 2
## 43 0 0 0
## 44 0 0 0
## 45 0 0 0
## 46 0 0 0
## 47 0 0 0
## 48 0 0 0
## 2024-03-07 10:07:00 2024-03-07 13:00:00 2024-03-07 17:00:00
## 1 0 0 0
## 2 1 1 1
## 3 0 0 0
## 4 3 3 3
## 5 4 4 4
## 6 4 4 4
## 7 0 0 0
## 8 0 0 0
## 9 2 2 2
## 10 1 1 1
## 11 1 1 1
## 12 3 3 3
## 13 0 0 0
## 14 0 0 0
## 15 0 0 0
## 16 1 1 1
## 17 1 1 1
## 18 0 0 1
## 19 2 2 2
## 20 4 4 4
## 21 4 4 4
## 22 6 6 6
## 23 6 6 6
## 24 2 2 2
## 25 1 1 0
## 26 0 0 0
## 27 1 1 1
## 28 1 1 1
## 29 0 0 0
## 30 1 1 1
## 31 0 0 0
## 32 0 0 0
## 33 0 0 0
## 34 0 0 0
## 35 0 0 0
## 36 0 0 0
## 37 0 0 0
## 38 1 1 1
## 39 0 0 0
## 40 0 0 0
## 41 0 0 0
## 42 2 3 3
## 43 0 0 0
## 44 0 0 0
## 45 0 0 0
## 46 0 0 0
## 47 0 0 0
## 48 0 0 0
## 2024-03-08 09:00:00 2024-03-08 13:07:00 2024-03-08 17:00:00
## 1 0 0 0
## 2 1 1 1
## 3 0 0 0
## 4 3 3 3
## 5 5 5 5
## 6 4 4 4
## 7 0 0 0
## 8 0 0 0
## 9 2 2 2
## 10 1 1 1
## 11 1 1 2
## 12 3 3 3
## 13 0 0 0
## 14 0 0 0
## 15 0 0 0
## 16 1 1 1
## 17 1 1 1
## 18 1 1 1
## 19 2 2 2
## 20 4 4 4
## 21 4 4 4
## 22 6 6 6
## 23 7 7 7
## 24 2 2 2
## 25 0 0 0
## 26 0 0 0
## 27 1 1 1
## 28 1 1 1
## 29 0 0 0
## 30 1 1 1
## 31 0 0 0
## 32 0 0 0
## 33 2 2 3
## 34 0 0 0
## 35 0 0 0
## 36 0 0 0
## 37 0 0 0
## 38 1 1 2
## 39 0 0 0
## 40 0 0 0
## 41 0 0 0
## 42 3 3 3
## 43 0 0 0
## 44 0 0 0
## 45 0 0 0
## 46 0 0 0
## 47 0 0 0
## 48 0 0 0
## 2024-03-09 10:05:00 2024-03-11 13:00:00 2024-03-12 12:40:00
## 1 0 0 0
## 2 1 1 1
## 3 0 0 0
## 4 3 3 3
## 5 5 5 5
## 6 4 4 5
## 7 0 0 0
## 8 0 0 1
## 9 2 16 16
## 10 1 1 1
## 11 2 2 18
## 12 3 17 17
## 13 0 0 0
## 14 0 0 0
## 15 0 0 0
## 16 1 1 1
## 17 1 1 1
## 18 1 1 1
## 19 2 19 20
## 20 4 4 4
## 21 5 5 5
## 22 6 6 7
## 23 6 6 7
## 24 2 2 4
## 25 0 0 0
## 26 0 0 0
## 27 1 1 1
## 28 1 1 1
## 29 0 0 0
## 30 1 2 3
## 31 0 0 0
## 32 0 0 1
## 33 8 9 9
## 34 0 0 0
## 35 0 0 0
## 36 0 0 5
## 37 0 0 0
## 38 2 2 2
## 39 0 0 0
## 40 0 0 0
## 41 0 0 0
## 42 3 4 4
## 43 0 0 0
## 44 1 1 1
## 45 0 0 0
## 46 0 0 0
## 47 0 0 0
## 48 0 0 5
install.packages("survival")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("survminer")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("viridis")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
library(survival)
library(survminer)
## Loading required package: ggpubr
##
## Attaching package: 'survminer'
## The following object is masked from 'package:survival':
##
## myeloma
library(viridis)
## Loading required package: viridisLite
install.packages("tidyverse")
## Installing package into '/home/catherinetaylor35/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
## also installing the dependencies 'textshaping', 'ragg'
## Warning in install.packages("tidyverse"): installation of package 'textshaping'
## had non-zero exit status
## Warning in install.packages("tidyverse"): installation of package 'ragg' had
## non-zero exit status
## Warning in install.packages("tidyverse"): installation of package 'tidyverse'
## had non-zero exit status
library(tidyr)
library(dplyr)
library(readr)
data_long <- data %>%
pivot_longer(
cols = 6:21,
names_to = "Time_Point",
values_to = "Deaths"
)
print(data_long)
## # A tibble: 768 × 7
## GENOTYPE FOOD SEX INFECTION REPLICATE Time_Point Deaths
## <chr> <chr> <chr> <chr> <chr> <chr> <dbl>
## 1 daxx[NP4778] Normal M vehicle 1 2024-03-04 19:15:00 0
## 2 daxx[NP4778] Normal M vehicle 1 2024-03-05 09:30:00 0
## 3 daxx[NP4778] Normal M vehicle 1 2024-03-05 13:20:00 0
## 4 daxx[NP4778] Normal M vehicle 1 2024-03-05 17:40:00 0
## 5 daxx[NP4778] Normal M vehicle 1 2024-03-06 09:10:00 0
## 6 daxx[NP4778] Normal M vehicle 1 2024-03-06 13:05:00 0
## 7 daxx[NP4778] Normal M vehicle 1 2024-03-06 16:59:00 0
## 8 daxx[NP4778] Normal M vehicle 1 2024-03-07 10:07:00 0
## 9 daxx[NP4778] Normal M vehicle 1 2024-03-07 13:00:00 0
## 10 daxx[NP4778] Normal M vehicle 1 2024-03-07 17:00:00 0
## # ℹ 758 more rows
data_long <- data_long %>% mutate(Time_Point = as.POSIXct(Time_Point))
print(data_long)
## # A tibble: 768 × 7
## GENOTYPE FOOD SEX INFECTION REPLICATE Time_Point Deaths
## <chr> <chr> <chr> <chr> <chr> <dttm> <dbl>
## 1 daxx[NP4778] Normal M vehicle 1 2024-03-04 19:15:00 0
## 2 daxx[NP4778] Normal M vehicle 1 2024-03-05 09:30:00 0
## 3 daxx[NP4778] Normal M vehicle 1 2024-03-05 13:20:00 0
## 4 daxx[NP4778] Normal M vehicle 1 2024-03-05 17:40:00 0
## 5 daxx[NP4778] Normal M vehicle 1 2024-03-06 09:10:00 0
## 6 daxx[NP4778] Normal M vehicle 1 2024-03-06 13:05:00 0
## 7 daxx[NP4778] Normal M vehicle 1 2024-03-06 16:59:00 0
## 8 daxx[NP4778] Normal M vehicle 1 2024-03-07 10:07:00 0
## 9 daxx[NP4778] Normal M vehicle 1 2024-03-07 13:00:00 0
## 10 daxx[NP4778] Normal M vehicle 1 2024-03-07 17:00:00 0
## # ℹ 758 more rows