This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.
library(tidyverse)
library(readr)
library(esquisse)
library(stringr)
Sheet <- read_csv("mmc1-2.csv")
Missing column names filled in: 'X20' [20], 'X21' [21]
── Column specification ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
cols(
.default = col_character(),
`Days between blood draws` = col_double(),
`Age (y)` = col_double(),
`Classical monocytes` = col_double(),
`Non-classical monocytes` = col_double(),
`NK cells` = col_double(),
`Naïve B cells` = col_double(),
X20 = col_logical(),
X21 = col_logical()
)
ℹ Use `spec()` for the full column specifications.
Sheet
Data <- select(Sheet, "Donor ID", "Sex", ends_with("monocytes"), ends_with("cells"))
Data
DataF <- filter(Data, Sex == "F")
DataF
DataFf<- as.data.frame(apply(DataF, 2, as.numeric))
NAs introduced by coercionNAs introduced by coercionNAs introduced by coercionNAs introduced by coercionNAs introduced by coercionNAs introduced by coercionNAs introduced by coercionNAs introduced by coercionNAs introduced by coercionNAs introduced by coercionNAs introduced by coercion
DataFf
DataM <- filter (Data, Sex == "M")
DataM
DataMm<- as.data.frame(apply(DataM, 2, as.numeric))
NAs introduced by coercionNAs introduced by coercion
DataMm
AverageF <- colMeans(DataFf, na.rm = TRUE, dims = 1)
AverageF
Donor ID Sex Classical monocytes Non-classical monocytes NK cells Naïve B cells Naïve CD4+\nT cells
55.6756757 NaN 17.1886364 1.3727273 6.3113636 5.4568182 12.1928571
Naïve CD8+\nT cells Naïve\nTREG cells Memory\nTREG cells TH1 cells TH1/17 cells TH17 cells TH2 cells
5.8928571 0.3928571 1.2357143 1.7047619 2.6119048 3.5023810 1.7142857
TFH cells
3.0095238
MeanF <- rbind(AverageF, DataFf, deparse.level = 1)
MeanF
MeanFf <- read_csv("Research - Sheet2.csv")
── Column specification ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
cols(
`Cell Type` = col_character(),
`Gene Expression` = col_double()
)
MeanFf
ggplot(MeanFf) +
aes(x = `Cell Type`, weight = `Gene Expression`) +
geom_bar(fill = "#6d9eeb") +
coord_flip() +
theme_minimal() +
ylim(0L, 20L)
AverageM <- colMeans(DataMm, na.rm = FALSE, dims = 1)
AverageM
Donor ID Sex Classical monocytes Non-classical monocytes NK cells Naïve B cells Naïve CD4+\nT cells
NA NA 18.2903226 1.6387097 8.1564516 5.1322581 10.3193548
Naïve CD8+\nT cells Naïve\nTREG cells Memory\nTREG cells TH1 cells TH1/17 cells TH17 cells TH2 cells
6.4274194 0.4935484 1.2129032 1.3306452 1.7612903 2.9354839 1.8451613
TFH cells
2.5500000
MeanM <- rbind(AverageM, DataMm, deparse.level = 1)
MeanM
MeanMm <- read_csv("Research - Sheet3.csv")
── Column specification ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
cols(
`Cell Type` = col_character(),
`Gene Expression` = col_double()
)
MeanMm
ggplot(MeanMm) +
aes(x = `Cell Type`, weight = `Gene Expression`) +
geom_bar(fill = "#bbc9d3") +
coord_flip() +
theme_minimal() +
ylim(0L, 20L)
Sum <- AverageF - AverageM
AbsSum <- abs(Sum)
Total <- rbind(AbsSum, Data, deparse.level = 1)
Total
TotalA <- read_csv("Research - Sheet1.csv")
── Column specification ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
cols(
`Cell Type` = col_character(),
`Gene Expression` = col_double()
)
TotalA
ggplot(TotalA) +
aes(x = `Cell Type`, weight = `Gene Expression`) +
geom_bar(fill = "#00e1c6") +
coord_flip() +
theme_minimal() +
ylim(0L, 2L)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.