-
Notifications
You must be signed in to change notification settings - Fork 8
/
720_mpif_example_selection.Rmd
96 lines (72 loc) · 3.21 KB
/
720_mpif_example_selection.Rmd
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
title: "MSK SPECTRUM data freeze: mpif example selection"
author: "Florian Uhlitz"
date: "`r Sys.Date()`"
output:
bookdown::html_document2:
includes:
in_header: header.html
bookdown::gitbook:
includes:
in_header: header.html
editor_options:
chunk_output_type: console
---
```{r chunk_720_010}
library(magrittr)
library(tidyverse)
library(Seurat)
library(readxl)
library(cowplot)
library(colorblindr)
library(viridis)
# library(magick, lib.loc = "/home/uhlitzf/miniconda3/lib/R/library")
library(ggpubr)
```
# load data modalities
```{r chunk_720_030}
## load global vars:
source("src/global_vars.R")
source("src/comp_plot.R")
# scrna_meta_tbl
# clrs
# markers_v7
# markers_v7_super
# cell_type_super_lookup
names(clrs$cell_type) <- str_replace_all(names(clrs$cell_type), "\\.", " ")
names(clrs$cell_type) <- str_replace_all(names(clrs$cell_type), "Ovarian", "Ov")
```
## mpIF
```{r chunk_720_050, fig.width=6, fig.height=3}
mpif_cell_state_expanded <- read_tsv("/work/shah/uhlitzf/data/SPECTRUM/mpIF/cell_type_manual_expanded_v10.tsv") %>%
select(cell_id, slide_id, fov_id, compartment, cell_type, cell_state, contains("state")) %>%
left_join(select(mpif_slide_meta_tbl, slide_id, patient_id_short, tumor_supersite, tumor_subsite, therapy, sample_id, consensus_signature, tumor_megasite), by = "slide_id") %>%
na.omit() %>%
mutate(sort_short_x = compartment) %>%
mutate(tumor_supersite = ordered(tumor_supersite, levels = rev(names(clrs$tumor_supersite)))) %>%
rename(cell_phenotype_short_mpif = cell_type,
cell_phenotype_mpif = cell_state)
mpif_cell_state_expanded <- mpif_cell_state_expanded %>%
mutate(cell_type_pd1n = ifelse(cell_phenotype_mpif %in% c("CD8+PD1-TOX-", "CD8+PD1-TOX+"), "CD8+PD1-", "other")) %>%
mutate(cell_type_pd1p = ifelse(cell_phenotype_mpif %in% c("CD8+PD1+TOX-", "CD8+PD1+TOX+"), "CD8+PD1+", "other")) %>%
mutate(cell_type_toxn = ifelse(cell_phenotype_mpif %in% c("CD8+PD1+TOX-", "CD8+PD1-TOX-"), "CD8+TOX-", "other")) %>%
mutate(cell_type_toxp = ifelse(cell_phenotype_mpif %in% c("CD8+PD1+TOX+", "CD8+PD1-TOX+"), "CD8+TOX+", "other"))
## cell state composition fov lvl
mpif_cell_state_n <- mpif_cell_state_expanded %>%
group_by(patient_id_short, tumor_supersite, tumor_subsite, tumor_megasite, therapy, sample_id, fov_id, consensus_signature, cell_phenotype_mpif, cell_phenotype_short_mpif, cell_type_pd1n, cell_type_pd1p, cell_type_toxn, cell_type_toxp) %>%
tally() %>%
group_by(patient_id_short, tumor_supersite, tumor_subsite, tumor_megasite, therapy, sample_id, fov_id, consensus_signature) %>%
mutate(nrel = n/sum(n)) %>%
ungroup()
```
# sample selection
```{r chunk_720_050, fig.width=6, fig.height=3}
mpif_cell_state_n %>%
filter(cell_phenotype_mpif == "panCK+PDL1+", tumor_supersite == "Adnexa",
consensus_signature %in% c("HRD-Del", "HRD-Dup", "FBI")) %>%
arrange(-n) %>%
View
# HRD-Dup: SPECTRUM-OV-007 LO CD68.TOX.PD1.PDL1.CD8.panCK_CK8-18.DAPI_[49322,9587]_component_data.tif - resolution #1
# HRD-Del: SPECTRUM-OV-036 LO CD68.TOX.PD1.PDL1.CD8.panCK_CK8-18.DAPI_[54013,18505]_component_data.tif - resolution #1
# FBI: SPECTRUM-OV-002 RA CD68.TOX.PD1.PDL1.CD8.panCK_CK8-18.DAPI_[59458,15870]_component_data.tif - resolution #1
```