-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRnaAgeCalc.R
More file actions
73 lines (42 loc) · 1.64 KB
/
RnaAgeCalc.R
File metadata and controls
73 lines (42 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("RNAAgeCalc")
library("RNAAgeCalc")
df_final <- df
rownames(df_final) = make.names(df_final$symbols, unique=TRUE)
df_final <- df_final[,-1]
fpkm_file <- count2FPKM(df_final, genelength = NULL, idtype = "SYMBOL")
TAE_sepsis_hancock <- predict_age(
df_final,
tissue = "blood",
exprtype = "counts",
idtype = "ENTREZID",
stype = "all",
signature = NULL,
genelength = NULL,
chronage = NULL,
maxp = NULL
)
TAE_sepsis_hancock$chrono_Age <- metadata_50sepsis$Age
TAE_sepsis_hancock$delta <- TAE_sepsis_hancock$RNAAge - TAE_sepsis_hancock$chrono_Age
library(tidyr)
library(dplyr)
# Sample Data
df <- data.frame(combined = c("S1_T1", "S2_T1", "S3_T2"), value = c(10, 15, 20))
# Split column "combined" into "SampleID" and "Timepoint" using "_"
df <- TAE_sepsis %>%
separate(col = IDs, into = c("sampleID", "timepoint"), sep = "_", convert = T)
# Create the spaghetti plot
ggplot(df, aes(x = df$timepoint, y = df$RNAAge, group = df$sampleID)) +
geom_line() + geom_smooth(aes(group = 1), method = "loess", color = "red", se = FALSE) +
labs(title = "Biological Age Over Time in Septic Patients - Whole Blood",
x = "Time Points (16h, 48h and Day 7)",
y = "RNA Age (years)") +
theme_minimal()
df2 <- df[, c("sampleID", "timepoint", "RNAAge")]
# one-way ANOVA
df2$timepoint <- as.factor(df2$timepoint)
anova_sepsis <- aov(df2$RNAAge ~ df2$timepoint + Error(df2$sampleID/df2$timepoint), data = df2)
summary(anova_sepsis)
#save final count matrix
write.table(TAE_sepsis_hancock, "~/Desktop/TAE_sepsis_hancock.tsv", sep="\t")