-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorso
More file actions
73 lines (61 loc) · 2.27 KB
/
Copy pathcorso
File metadata and controls
73 lines (61 loc) · 2.27 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
=> Controllare che tutti vedano e sentano
=> Giro di presentazioni
=> Premettere che questa sarà una chiacchierata
=> DOMANDE?
=> Per cosa pensate di dover usare R
Cosa preferite fare oggi:
- Carichiamo un dataset e proviamo a modificarlo e disegnare plots
- Qualcuno ha un dataset da provare d usare
- Qualcuno ha un'immagine per un articolo che non sa come create
- Prendiamo il codice di un'immagine ed esaminiamolo
1. Load tidyverse
2. Download data
3. Descrizione del dataset
4. SELECT
- gene, sample, tissue, expression
- remove columns
- select with helper functions
5. FILTER
- sex == "Male"
- sex == "Male" & infection == "NonInfected"
- Cosa volete filtrare?
- Valori compresi tra
- Valori higher or lower
- Subset di geni (create lista e usare operatore %in%)
6. Combine FILTER e SELECT con il pipe operator
=> Challange: subset with genes higher than 50000, male mice, time 0, and retain only the columns gene, sample, time, expression and age
7. MUTATE
- Update/create a new column time to hours: mutate(time_hours = time * 24)
- mutate(time_hours = time * 24, time_mn = time_hours * 60)
7. Gruop_by/summarise
- group_by(gene) %>% summarize(mean_expression = mean(expression))
- summarise su diverse colonne
- arrange
- counting (long and short format)
8. Pivoting
- rna_exp <- rna %>%
select(gene, sample, expression)
- rna_wide <- rna_exps %>%
pivot_wider(names_from = sample,
values_from = expression,
values_fill = 0)
- rna_long <- rna_wide %>%
pivot_longer(cols = -gene,
names_to = "sample",
values_to = "expression"
)
rna %>%
mutate(expression_log = log(expression)) %>%
group_by(gene, time) %>%
summarize(mean_exp = mean(expression_log)) %>%
pivot_wider(names_from = time,
values_from = mean_exp) %>%
mutate(time_8_vs_0 = `8` - `0`, time_4_vs_0 = `4` - `0`) %>%
select(gene, time_8_vs_0, time_4_vs_0)
rna_fc <- rna %>% select(gene, time,
gene_biotype, expression_log) %>%
group_by(gene, time, gene_biotype) %>%
summarize(mean_exp = mean(expression_log)) %>%
pivot_wider(names_from = time,
values_from = mean_exp) %>%
mutate(time_8_vs_0 = `8` - `0`, time_4_vs_0 = `4` - `0`)