Using small_brca as your tibble, write code that reports the gene with the highest count in each tumor sample.
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.4 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
load("/cloud/project/data/small_brca.Rdata")
small_brca %>%
filter(tumor == TRUE) %>%
select(ANLN:TMEM45B) %>%
rowwise() %>%
summarise(highest.gene = names(.)[which.max(c_across(ANLN:TMEM45B))],
max.value = max(c_across(ANLN:TMEM45B)),
.groups = 'drop')
## # A tibble: 1,102 x 2
## highest.gene max.value
## <chr> <dbl>
## 1 MMP11 108677
## 2 MMP11 89135
## 3 SLC39A6 138393
## 4 KRT5 102256
## 5 ESR1 133812
## 6 ERBB2 811281
## 7 SLC39A6 70814
## 8 KRT14 198790
## 9 SLC39A6 53480
## 10 SLC39A6 305439
## # … with 1,092 more rows