-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ad_SF7_predict_2nd.R
1795 lines (1321 loc) · 64.4 KB
/
Ad_SF7_predict_2nd.R
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## script for predicting Ad-SF7-Fc activation or inhibition
#3/18/2021
#A higher SLAMF7_score means a cell looks more like a WT cell and less like a SF7-KO cell (since I subtracted SF7-KO from WT)
#-----------------------------
#let's start w/ NK cells
#Packages
library(CATALYST)
library(tidyverse)
library(readxl)
library(ggplot2)
#library(RColorBrewer)
#library(xlsx)
setwd("~/B16_TME_profiling_batch2_analys")
#load the data
daf_X_clean <- readRDS(file = "./daf_X_clean.rds")
daf_X_NK <- filterSCE(daf_X_clean, cluster_id == "NK cells", k = "merging1")
#---------------Get marker differences b/w KO (Ad-null) and WT (Ad-null)
#Subset to only KO
daf_X_NK_KO <- filterSCE(daf_X_NK, genotype == "SLAMF7_KO")
levels(daf_X_NK_KO$genotype)
KO_NK_med_mtx <- data.frame(colData(daf_X_NK_KO), t(assay(daf_X_NK_KO, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
KO_NK_med_mtx <- KO_NK_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_NK_KO <- KO_NK_med_mtx %>%
summarise_all(median)
#now WT
#Subset to only WT
daf_X_NK_WT <- filterSCE(daf_X_NK, genotype == "WT")
levels(daf_X_NK_WT$genotype)
WT_NK_med_mtx <- data.frame(colData(daf_X_NK_WT), t(assay(daf_X_NK_WT, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
WT_NK_med_mtx <- WT_NK_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_NK_WT <- WT_NK_med_mtx %>%
summarise_all(median)
#I want the signature of what cell with SLAMF7 signaling looks like so I subtract KO values from WT values
mark_diff <- t(mark_stats_NK_WT-mark_stats_NK_KO) %>%
as.data.frame() %>%
arrange(., desc(V1)) %>%
rownames_to_column(., "markers")
#from a visual inspection it looks like I should be able to use the top 4 and bottom 4 markers as a signature.
##---------Get NK cell KO marker signature---------------
high <- mark_diff[1:4,]
low <- mark_diff[22:25,]
SF7_KO_sig_NK <- bind_rows("up" = high, "down" = low, .id = "sign")
##---------Sum marker expression of NK sig markers in Ad-SF7-Fc NK cells and generate score---------
#subset to only Ad-Sf7-Fc group
daf_X_NK_SF7_Fc <- filterSCE(daf_X_NK, condition == "Ad_SLAMF7_Fc")
levels(daf_X_NK_SF7_Fc$condition)
Ad_SF7_exprs_NK <- data.frame(colData(daf_X_NK_SF7_Fc), t(assay(daf_X_NK_SF7_Fc, "exprs")), check.names = FALSE)
#clean up
Ad_SF7_exprs_NK <- Ad_SF7_exprs_NK %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#subset out high sig markers and get pan-high marker score
SF7_Fc_high <- Ad_SF7_exprs_NK %>%
select(one_of("CD11c", "NK1.1", "CD11b", "Ly6C")) %>%
transmute(sum = rowSums(across(where(is.numeric))))
#subset out low sig markers and get pan-low marker score
SF7_Fc_low <- Ad_SF7_exprs_NK %>%
select(one_of("CD90", "B220", "CD38", "PD-L1")) %>%
transmute(sum = rowSums(across(where(is.numeric))))
#subtract low values from high and normalize by total marker number (on a per cell basis)
high_low_dif <- (SF7_Fc_high - SF7_Fc_low)/8
high_low_dif <- high_low_dif %>%
rownames_to_column('rn')
#rename score
names(high_low_dif)[2] <- "SLAMF7_score"
##---------Join SLAMF7_score back to main expression df---------
#Add SLAMF7 scores back to main expression df
Ad_SF7_fc_scored_NK <- data.frame(colData(daf_X_NK_SF7_Fc), t(assay(daf_X_NK_SF7_Fc, "exprs")), check.names = FALSE) %>%
rownames_to_column('rn')
Ad_SF7_fc_scored_NK <- left_join(Ad_SF7_fc_scored_NK, high_low_dif, by = "rn")
##-------------------Now plot it!----------------
#now make scatter plot of SLAMF7_score by SLAMF7 expression
score_plot_NK <- ggplot(Ad_SF7_fc_scored_NK, aes(x=SLAMF7_score, y=SLAMF7)) +
geom_point(size=0.6, alpha = 0.5) +
scale_fill_manual(values = c("#b3b3b3"))
score_plot_NK + theme(axis.line = element_line(linetype = "solid"),
axis.ticks = element_line(size = 0.9),
axis.title = element_text(size = 15),
axis.text = element_text(size = 14, colour = "black"),
axis.text.x = element_text(size = 14),
panel.background = element_rect(fill = NA))
#subset out high sig markers and get pan-high marker score
SF7_KO_high <- KO_NK_med_mtx %>%
select(one_of("CD11c", "NK1.1", "CD11b", "Ly6C")) %>%
transmute(sum = rowSums(across(where(is.numeric))))
#subset out low sig markers and get pan-low marker score
SF7_KO_low <- KO_NK_med_mtx %>%
select(one_of("CD90", "B220", "CD38", "PD-L1")) %>%
transmute(sum = rowSums(across(where(is.numeric))))
#subtract low values from high and normalize by total marker number (on a per cell basis)
high_low_dif_KO <- (SF7_KO_high - SF7_KO_low)/8
high_low_dif_KO <- high_low_dif_KO %>%
rownames_to_column('rn')
#rename score
names(high_low_dif_KO)[2] <- "SLAMF7_score"
#Add SLAMF7 scores back to main expression df
KO_NK_med_mtx <- data.frame(colData(daf_X_NK_KO), t(assay(daf_X_NK_KO, "exprs")), check.names = FALSE) %>%
rownames_to_column('rn')
SF7_KO_scored <- left_join(KO_NK_med_mtx, high_low_dif_KO, by = "rn")
#merge SF7_KO_scored to Ad_SF7_Fc_scored
KO_and_Fc_scored <- bind_rows(SF7_KO_scored, Ad_SF7_fc_scored_NK)
#check it
table(KO_and_Fc_scored$condition, KO_and_Fc_scored$genotype)
#Now plot
score_plot <- ggplot(KO_and_Fc_scored, aes(x=SLAMF7_score, y=SLAMF7, color = genotype )) +
geom_point(size=0.5, alpha = 0.5) +
scale_fill_manual(values = c("#b3b3b3"))
score_plot + theme(axis.line = element_line(linetype = "solid"),
axis.ticks = element_line(size = 0.9),
axis.title = element_text(size = 15),
axis.text = element_text(size = 14, colour = "black"),
axis.text.x = element_text(size = 14),
panel.background = element_rect(fill = NA))
##---------now trying w/ Dr. Carlson's approach-------------##
#subset to pertinant data
diag_calc <- Ad_SF7_fc_scored_NK %>%
select(one_of("SLAMF7", "SLAMF7_score")) %>%
as.data.frame(.)
#get quantiles
SF7q <- quantile(diag_calc$SLAMF7)
SF7_scoreq <- quantile(diag_calc$SLAMF7_score)
#Now plot the data and identify a line that passes through the lower left quantile intersection and the
#upper right quantile intersection. Then use the slope to identify parallel lines that pass through
#the upper left and lower right intersections:
plot(diag_calc$SLAMF7~diag_calc$SLAMF7_score, diag_calc, pch=20)
abline(v=SF7_scoreq[2:4], lty=3)
abline(h=SF7q[2:4], lty=3)
diag <- lm(SF7q[c(2, 4)]~SF7_scoreq[c(2, 4)])
points(SF7_scoreq[c(2, 4)], SF7q[c(2, 4)], cex=2, col="red", lwd=2)
abline(diag)
b <- coef(diag)[2]
a1 <- SF7q[4] - b * SF7_scoreq[2]
a2 <- SF7q[2] - b * SF7_scoreq[4]
abline(a1, b)
abline(a2, b)
#Now identify all points above and below the 2 diagonal lines
res1 <- diag_calc$SLAMF7 - (a1 + b * diag_calc$SLAMF7_score)
res2 <- (a2 + b * diag_calc$SLAMF7_score) - diag_calc$SLAMF7
clr <- c("black", "purple", "darkorange")
idx <- ifelse(res1 > 0, 3, ifelse(res2 > 0, 2, 1))
plot(diag_calc$SLAMF7~diag_calc$SLAMF7_score, pch=20, col=clr[idx])
abline(a1, b, col="red")
abline(a2, b, col="red")
#Get identification of outlier points
position <- c("neither", "activated", "blocked")
diag_calc$outlier <- position[idx]
diag_calc <- diag_calc %>% rownames_to_column('rn')
#remove SF7 and SF7_score so no redundancy when I join
diag_calc <- diag_calc %>%
select(., rn, outlier)
head(diag_calc)
#Join calls of outlier points back to main df
Ad_SF7_fc_scored_NK_called <- left_join(Ad_SF7_fc_scored_NK, diag_calc, by = "rn")
#Now plot (nicely) (WORKS BEAUTIFULY)
score_plot2 <- ggplot(Ad_SF7_fc_scored_NK_called, aes(x=SLAMF7_score, y=SLAMF7, color = outlier, group = outlier)) +
geom_point(aes(size = outlier), alpha = 0.9) +
scale_size_manual(values=c(3,3,1.2)) +
scale_color_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
score_plot2 + theme(axis.line = element_line(linetype = "solid"),
axis.ticks = element_line(size = 0.9),
axis.title = element_text(size = 15),
axis.text = element_text(size = 14, colour = "black"),
axis.text.x = element_text(size = 14),
panel.background = element_rect(fill = NA))
#make pie chart of proportion of outlier calls
NK_pred_pie <- table(
outlier = Ad_SF7_fc_scored_NK_called$outlier,
condition = Ad_SF7_fc_scored_NK_called$condition) %>%
as.data.frame(.)
ggplot(data=NK_pred_pie, aes(x="", y=Freq, fill=outlier)) +
geom_bar(stat="identity", width = 1, color = "white") +
coord_polar("y", start = 0) +
theme_void() +
scale_fill_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
NK_pred_pie
sum(NK_pred_pie$Freq)
##-----------------Now repeat for DCs--------------------##
#load the data
daf_X_clean <- readRDS(file = "./daf_X_clean.rds")
daf_X_DC <- filterSCE(daf_X_clean, cluster_id == "DCs", k = "merging1")
#---------------Get marker differences b/w KO (Ad-null) and WT (Ad-null)
#Subset to only KO
daf_X_DC_KO <- filterSCE(daf_X_DC, genotype == "SLAMF7_KO")
levels(daf_X_DC_KO$genotype)
KO_DC_med_mtx <- data.frame(colData(daf_X_DC_KO), t(assay(daf_X_DC_KO, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
KO_DC_med_mtx <- KO_DC_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_DC_KO <- KO_DC_med_mtx %>%
summarise_all(median)
#now WT
#Subset to only WT
daf_X_DC_WT <- filterSCE(daf_X_DC, genotype == "WT")
levels(daf_X_DC_WT$genotype)
WT_DC_med_mtx <- data.frame(colData(daf_X_DC_WT), t(assay(daf_X_DC_WT, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
WT_DC_med_mtx <- WT_DC_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_DC_WT <- WT_DC_med_mtx %>%
summarise_all(median)
#I want the signature of what cell with SLAMF7 signaling looks like so I subtract KO values from WT values
mark_diff <- t(mark_stats_DC_WT-mark_stats_DC_KO) %>%
as.data.frame() %>%
arrange(., desc(V1)) %>%
rownames_to_column(., "markers")
#from a visual inspection it looks like I should be able to use the top 4 and bottom 4 markers as a signature.
##---------Get NK cell KO marker signature---------------
high <- mark_diff[1:4,]
low <- mark_diff[22:25,]
SF7_KO_sig_DC <- bind_rows("up" = high, "down" = low, .id = "sign")
##---------Sum marker expression of DC sig markers in Ad-SF7-Fc NK cells and generate score---------
#subset to only Ad-Sf7-Fc group
daf_X_DC_SF7_Fc <- filterSCE(daf_X_DC, condition == "Ad_SLAMF7_Fc")
levels(daf_X_DC_SF7_Fc$condition)
Ad_SF7_exprs_DC <- data.frame(colData(daf_X_DC_SF7_Fc), t(assay(daf_X_DC_SF7_Fc, "exprs")), check.names = FALSE)
#clean up
Ad_SF7_exprs_DC <- Ad_SF7_exprs_DC %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#subset out high sig markers and get pan-high marker score
SF7_Fc_high <- Ad_SF7_exprs_DC %>%
select(one_of("CD11c", "PD-L1", "AF", "Ly6C")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subset out low sig markers and get pan-low marker score
SF7_Fc_low <- Ad_SF7_exprs_DC %>%
select(one_of("Lyve-1", "CD4", "CD38", "Fascin")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subtract low values from high and normalize by total marker number (on a per cell basis)
high_low_dif <- (SF7_Fc_high - SF7_Fc_low)/8
high_low_dif <- high_low_dif %>%
rownames_to_column('rn')
#rename score
names(high_low_dif)[2] <- "SLAMF7_score"
##---------Join SLAMF7_score back to main expression df---------
#Add SLAMF7 scores back to main expression df
Ad_SF7_fc_scored_DC <- data.frame(colData(daf_X_DC_SF7_Fc), t(assay(daf_X_DC_SF7_Fc, "exprs")), check.names = FALSE) %>%
rownames_to_column('rn')
Ad_SF7_fc_scored_DC <- left_join(Ad_SF7_fc_scored_DC, high_low_dif, by = "rn")
summary(Ad_SF7_fc_scored_DC$SLAMF7_score)
##---------now trying w/ Dr. Carlson's approach-------------##
#subset to pertinant data
diag_calc <- Ad_SF7_fc_scored_DC %>%
select(one_of("SLAMF7", "SLAMF7_score")) %>%
as.data.frame(.)
#get quantiles
SF7q <- quantile(diag_calc$SLAMF7)
SF7_scoreq <- quantile(diag_calc$SLAMF7_score)
#Now plot the data and identify a line that passes through the lower left quantile intersection and the
#upper right quantile intersection. Then use the slope to identify parallel lines that pass through
#the upper left and lower right intersections:
diag <- lm(SF7q[c(2, 4)]~SF7_scoreq[c(2, 4)])
b <- coef(diag)[2]
a1 <- SF7q[4] - b * SF7_scoreq[2]
a2 <- SF7q[2] - b * SF7_scoreq[4]
#Now identify all points above and below the 2 diagonal lines
res1 <- diag_calc$SLAMF7 - (a1 + b * diag_calc$SLAMF7_score)
res2 <- (a2 + b * diag_calc$SLAMF7_score) - diag_calc$SLAMF7
idx <- ifelse(res1 > 0, 3, ifelse(res2 > 0, 2, 1))
#Get identification of outlier points
position <- c("neither", "activated", "blocked")
diag_calc$outlier <- position[idx]
diag_calc <- diag_calc %>% rownames_to_column('rn')
#remove SF7 and SF7_score so no redundancy when I join
diag_calc <- diag_calc %>%
select(., rn, outlier)
head(diag_calc)
#Join calls of outlier points back to main df
Ad_SF7_fc_scored_DC_called <- left_join(Ad_SF7_fc_scored_DC, diag_calc, by = "rn")
#Now plot (nicely) (WORKS BEAUTIFULY)
score_plot2 <- ggplot(Ad_SF7_fc_scored_DC_called, aes(x=SLAMF7_score, y=SLAMF7, color = outlier, group = outlier)) +
geom_point(aes(size = outlier), alpha = 0.9) +
scale_size_manual(values=c(1.5,1.5,0.9)) + #change point sizes based on number of cells
scale_color_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
score_plot2 + theme(axis.line = element_line(linetype = "solid"),
axis.ticks = element_line(size = 0.9),
axis.title = element_text(size = 15),
axis.text = element_text(size = 14, colour = "black"),
axis.text.x = element_text(size = 14),
panel.background = element_rect(fill = NA))
#make pie chart of proportion of outlier calls
DC_pred_pie <- table(
outlier = Ad_SF7_fc_scored_DC_called$outlier,
condition = Ad_SF7_fc_scored_DC_called$condition) %>%
as.data.frame(.)
ggplot(data=DC_pred_pie, aes(x="", y=Freq, fill=outlier)) +
geom_bar(stat="identity", width = 1, color = "white") +
coord_polar("y", start = 0) +
theme_void() +
scale_fill_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
DC_pred_pie
sum(DC_pred_pie$Freq)
##-----------------Now repeat for TAMs--------------------##
#load the data
daf_X_clean <- readRDS(file = "./daf_X_clean.rds")
daf_X_TAM <- filterSCE(daf_X_clean, cluster_id == "TAMs", k = "merging1")
#---------------Get marker differences b/w KO (Ad-null) and WT (Ad-null)
#Subset to only KO
daf_X_tam_KO <- filterSCE(daf_X_TAM, genotype == "SLAMF7_KO")
levels(daf_X_tam_KO$genotype)
KO_tam_med_mtx <- data.frame(colData(daf_X_tam_KO), t(assay(daf_X_tam_KO, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
KO_tam_med_mtx <- KO_tam_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_tam_KO <- KO_tam_med_mtx %>%
summarise_all(median)
#now WT
#Subset to only WT
daf_X_tam_WT <- filterSCE(daf_X_TAM, genotype == "WT")
levels(daf_X_tam_WT$genotype)
WT_tam_med_mtx <- data.frame(colData(daf_X_tam_WT), t(assay(daf_X_tam_WT, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
WT_tam_med_mtx <- WT_tam_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_tam_WT <- WT_tam_med_mtx %>%
summarise_all(median)
#I want the signature of what cell with SLAMF7 signaling looks like so I subtract KO values from WT values
mark_diff <- t(mark_stats_tam_WT-mark_stats_tam_KO) %>%
as.data.frame() %>%
arrange(., desc(V1)) %>%
rownames_to_column(., "markers")
##---------Get tam cell KO marker signature---------------
high <- mark_diff[1:5,] #I increased the number of markers here since more were strongly changed
low <- mark_diff[22:25,]
SF7_KO_sig_tam <- bind_rows("up" = high, "down" = low, .id = "sign")
##---------Sum marker expression of tam sig markers in Ad-SF7-Fc tam cells and generate score---------
#subset to only Ad-Sf7-Fc group
daf_X_tam_SF7_Fc <- filterSCE(daf_X_TAM, condition == "Ad_SLAMF7_Fc")
levels(daf_X_tam_SF7_Fc$condition)
Ad_SF7_exprs_tam <- data.frame(colData(daf_X_tam_SF7_Fc), t(assay(daf_X_tam_SF7_Fc, "exprs")), check.names = FALSE)
#clean up
Ad_SF7_exprs_tam <- Ad_SF7_exprs_tam %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#subset out high sig markers and get pan-high marker score
SF7_Fc_high <- Ad_SF7_exprs_tam %>%
select(one_of("CD11c", "CD45", "CD11b", "PD-L1", "MHC-II")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subset out low sig markers and get pan-low marker score
SF7_Fc_low <- Ad_SF7_exprs_tam %>%
select(one_of("CD38", "F4/80", "AF", "CD206")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subtract low values from high and normalize by total marker number (on a per cell basis)
high_low_dif <- (SF7_Fc_high - SF7_Fc_low)/9 #changed denominator since I added a marker
high_low_dif <- high_low_dif %>%
rownames_to_column('rn')
#rename score
names(high_low_dif)[2] <- "SLAMF7_score"
##---------Join SLAMF7_score back to main expression df---------
#Add SLAMF7 scores back to main expression df
Ad_SF7_fc_scored_tam <- data.frame(colData(daf_X_tam_SF7_Fc), t(assay(daf_X_tam_SF7_Fc, "exprs")), check.names = FALSE) %>%
rownames_to_column('rn')
Ad_SF7_fc_scored_tam <- left_join(Ad_SF7_fc_scored_tam, high_low_dif, by = "rn")
summary(Ad_SF7_fc_scored_tam$SLAMF7_score)
##---------now trying w/ Dr. Carlson's approach-------------##
#subset to pertinant data
diag_calc <- Ad_SF7_fc_scored_tam %>%
select(one_of("SLAMF7", "SLAMF7_score")) %>%
as.data.frame(.)
#get quantiles
SF7q <- quantile(diag_calc$SLAMF7)
SF7_scoreq <- quantile(diag_calc$SLAMF7_score)
#Now plot the data and identify a line that passes through the lower left quantile intersection and the
#upper right quantile intersection. Then use the slope to identify parallel lines that pass through
#the upper left and lower right intersections:
diag <- lm(SF7q[c(2, 4)]~SF7_scoreq[c(2, 4)])
b <- coef(diag)[2]
a1 <- SF7q[4] - b * SF7_scoreq[2]
a2 <- SF7q[2] - b * SF7_scoreq[4]
#Now identify all points above and below the 2 diagonal lines
res1 <- diag_calc$SLAMF7 - (a1 + b * diag_calc$SLAMF7_score)
res2 <- (a2 + b * diag_calc$SLAMF7_score) - diag_calc$SLAMF7
idx <- ifelse(res1 > 0, 3, ifelse(res2 > 0, 2, 1))
#Get identification of outlier points
position <- c("neither", "activated", "blocked")
diag_calc$outlier <- position[idx]
diag_calc <- diag_calc %>% rownames_to_column('rn')
#remove SF7 and SF7_score so no redundancy when I join
diag_calc <- diag_calc %>%
select(., rn, outlier)
head(diag_calc)
#Join calls of outlier points back to main df
Ad_SF7_fc_scored_tam_called <- left_join(Ad_SF7_fc_scored_tam, diag_calc, by = "rn")
#Now plot (nicely) (WORKS BEAUTIFULY)
score_plot2 <- ggplot(Ad_SF7_fc_scored_tam_called, aes(x=SLAMF7_score, y=SLAMF7, color = outlier, group = outlier)) +
geom_point(aes(size = outlier), alpha = 0.9) +
scale_size_manual(values=c(1.5,1.5,0.9)) + #change point sizes based on number of cells
scale_color_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
score_plot2 + theme(axis.line = element_line(linetype = "solid"),
axis.ticks = element_line(size = 0.9),
axis.title = element_text(size = 15),
axis.text = element_text(size = 14, colour = "black"),
axis.text.x = element_text(size = 14),
panel.background = element_rect(fill = NA))
#make pie chart of proportion of outlier calls
tam_pred_pie <- table(
outlier = Ad_SF7_fc_scored_tam_called$outlier,
condition = Ad_SF7_fc_scored_tam_called$condition) %>%
as.data.frame(.)
ggplot(data=tam_pred_pie, aes(x="", y=Freq, fill=outlier)) +
geom_bar(stat="identity", width = 1, color = "white") +
coord_polar("y", start = 0) +
theme_void() +
scale_fill_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
tam_pred_pie
sum(tam_pred_pie$Freq)
##-----------------Now repeat for CD8+ T cells--------------------##
#load the data
daf_X_clean <- readRDS(file = "./daf_X_clean.rds")
daf_X_cd8 <- filterSCE(daf_X_clean, cluster_id == "CD8+ T cells", k = "merging1")
#---------------Get marker differences b/w KO (Ad-null) and WT (Ad-null)
#Subset to only KO
daf_X_cd8_KO <- filterSCE(daf_X_cd8, genotype == "SLAMF7_KO")
levels(daf_X_cd8_KO$genotype)
KO_cd8_med_mtx <- data.frame(colData(daf_X_cd8_KO), t(assay(daf_X_cd8_KO, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
KO_cd8_med_mtx <- KO_cd8_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_cd8_KO <- KO_cd8_med_mtx %>%
summarise_all(median)
#now WT
#Subset to only WT
daf_X_cd8_WT <- filterSCE(daf_X_cd8, genotype == "WT")
levels(daf_X_cd8_WT$genotype)
WT_cd8_med_mtx <- data.frame(colData(daf_X_cd8_WT), t(assay(daf_X_cd8_WT, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
WT_cd8_med_mtx <- WT_cd8_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_cd8_WT <- WT_cd8_med_mtx %>%
summarise_all(median)
#I want the signature of what cell with SLAMF7 signaling looks like so I subtract KO values from WT values
mark_diff <- t(mark_stats_cd8_WT-mark_stats_cd8_KO) %>%
as.data.frame() %>%
arrange(., desc(V1)) %>%
rownames_to_column(., "markers")
##---------Get tam cell KO marker signature---------------
high <- mark_diff[1:3,] #only top 3 since I do not want to include IgD
low <- mark_diff[21:25,] #last 5
SF7_KO_sig_cd8 <- bind_rows("up" = high, "down" = low, .id = "sign")
##---------Sum marker expression of sig markers in Ad-SF7-Fc cd8 cells and generate score---------
#subset to only Ad-Sf7-Fc group
daf_X_cd8_SF7_Fc <- filterSCE(daf_X_cd8, condition == "Ad_SLAMF7_Fc")
levels(daf_X_cd8_SF7_Fc$condition)
Ad_SF7_exprs_cd8 <- data.frame(colData(daf_X_cd8_SF7_Fc), t(assay(daf_X_cd8_SF7_Fc, "exprs")), check.names = FALSE)
#clean up
Ad_SF7_exprs_cd8 <- Ad_SF7_exprs_cd8 %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#subset out high sig markers and get pan-high marker score
SF7_Fc_high <- Ad_SF7_exprs_cd8 %>%
select(one_of("Ly6C", "AF", "CD90")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subset out low sig markers and get pan-low marker score
SF7_Fc_low <- Ad_SF7_exprs_cd8 %>%
select(one_of("CD38", "CD4", "Fascin", "NK1.1", "CD11c")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subtract low values from high and normalize by total marker number (on a per cell basis)
high_low_dif <- (SF7_Fc_high - SF7_Fc_low)/8
high_low_dif <- high_low_dif %>%
rownames_to_column('rn')
#rename score
names(high_low_dif)[2] <- "SLAMF7_score"
##---------Join SLAMF7_score back to main expression df---------
#Add SLAMF7 scores back to main expression df
Ad_SF7_fc_scored_cd8 <- data.frame(colData(daf_X_cd8_SF7_Fc), t(assay(daf_X_cd8_SF7_Fc, "exprs")), check.names = FALSE) %>%
rownames_to_column('rn')
Ad_SF7_fc_scored_cd8 <- left_join(Ad_SF7_fc_scored_cd8, high_low_dif, by = "rn")
summary(Ad_SF7_fc_scored_cd8$SLAMF7_score)
##---------now trying w/ Dr. Carlson's approach-------------##
#subset to pertinant data
diag_calc <- Ad_SF7_fc_scored_cd8 %>%
select(one_of("SLAMF7", "SLAMF7_score")) %>%
as.data.frame(.)
#get quantiles
SF7q <- quantile(diag_calc$SLAMF7)
SF7_scoreq <- quantile(diag_calc$SLAMF7_score)
#Now plot the data and identify a line that passes through the lower left quantile intersection and the
#upper right quantile intersection. Then use the slope to identify parallel lines that pass through
#the upper left and lower right intersections:
diag <- lm(SF7q[c(2, 4)]~SF7_scoreq[c(2, 4)])
b <- coef(diag)[2]
a1 <- SF7q[4] - b * SF7_scoreq[2]
a2 <- SF7q[2] - b * SF7_scoreq[4]
#Now identify all points above and below the 2 diagonal lines
res1 <- diag_calc$SLAMF7 - (a1 + b * diag_calc$SLAMF7_score)
res2 <- (a2 + b * diag_calc$SLAMF7_score) - diag_calc$SLAMF7
idx <- ifelse(res1 > 0, 3, ifelse(res2 > 0, 2, 1))
#Get identification of outlier points
position <- c("neither", "activated", "blocked")
diag_calc$outlier <- position[idx]
diag_calc <- diag_calc %>% rownames_to_column('rn')
#remove SF7 and SF7_score so no redundancy when I join
diag_calc <- diag_calc %>%
select(., rn, outlier)
head(diag_calc)
#Join calls of outlier points back to main df
Ad_SF7_fc_scored_cd8_called <- left_join(Ad_SF7_fc_scored_cd8, diag_calc, by = "rn")
#Now plot (nicely) (WORKS BEAUTIFULY)
score_plot2 <- ggplot(Ad_SF7_fc_scored_cd8_called, aes(x=SLAMF7_score, y=SLAMF7, color = outlier, group = outlier)) +
geom_point(aes(size = outlier), alpha = 0.9) +
scale_size_manual(values=c(1.5,1.5,0.9)) + #change point sizes based on number of cells
scale_color_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
score_plot2 + theme(axis.line = element_line(linetype = "solid"),
axis.ticks = element_line(size = 0.9),
axis.title = element_text(size = 15),
axis.text = element_text(size = 14, colour = "black"),
axis.text.x = element_text(size = 14),
panel.background = element_rect(fill = NA))
#make pie chart of proportion of outlier calls
cd8_pred_pie <- table(
outlier = Ad_SF7_fc_scored_cd8_called$outlier,
condition = Ad_SF7_fc_scored_cd8_called$condition) %>%
as.data.frame(.)
ggplot(data=cd8_pred_pie, aes(x="", y=Freq, fill=outlier)) +
geom_bar(stat="identity", width = 1, color = "white") +
coord_polar("y", start = 0) +
theme_void() +
scale_fill_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
cd8_pred_pie
sum(cd8_pred_pie$Freq)
##-----------------Now repeat for pdcs--------------------##
#load the data
daf_X_clean <- readRDS(file = "./daf_X_clean.rds")
daf_X_pdc <- filterSCE(daf_X_clean, cluster_id == "pDCs", k = "merging1")
#---------------Get marker differences b/w KO (Ad-null) and WT (Ad-null)
#Subset to only KO
daf_X_pdc_KO <- filterSCE(daf_X_pdc, genotype == "SLAMF7_KO")
levels(daf_X_pdc_KO$genotype)
KO_pdc_med_mtx <- data.frame(colData(daf_X_pdc_KO), t(assay(daf_X_pdc_KO, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
KO_pdc_med_mtx <- KO_pdc_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_pdc_KO <- KO_pdc_med_mtx %>%
summarise_all(median)
#now WT
#Subset to only WT
daf_X_pdc_WT <- filterSCE(daf_X_pdc, genotype == "WT")
levels(daf_X_pdc_WT$genotype)
WT_pdc_med_mtx <- data.frame(colData(daf_X_pdc_WT), t(assay(daf_X_pdc_WT, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
WT_pdc_med_mtx <- WT_pdc_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_pdc_WT <- WT_pdc_med_mtx %>%
summarise_all(median)
#I want the signature of what cell with SLAMF7 signaling looks like so I subtract KO values from WT values
mark_diff <- t(mark_stats_pdc_WT-mark_stats_pdc_KO) %>%
as.data.frame() %>%
arrange(., desc(V1)) %>%
rownames_to_column(., "markers")
##---------Get tam cell KO marker signature---------------
high <- mark_diff[1:4,] #top 4, but remove IgD
low <- mark_diff[22:25,]
SF7_KO_sig_pdc <- bind_rows("up" = high, "down" = low, .id = "sign")
SF7_KO_sig_pdc <- SF7_KO_sig_pdc[-3,]
##---------Sum marker expression of sig markers in Ad-SF7-Fc pDCs cells and generate score---------
#subset to only Ad-Sf7-Fc group
daf_X_pdc_SF7_Fc <- filterSCE(daf_X_pdc, condition == "Ad_SLAMF7_Fc")
levels(daf_X_pdc_SF7_Fc$condition)
Ad_SF7_exprs_pdc <- data.frame(colData(daf_X_pdc_SF7_Fc), t(assay(daf_X_pdc_SF7_Fc, "exprs")), check.names = FALSE)
#clean up
Ad_SF7_exprs_pdc <- Ad_SF7_exprs_pdc %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#subset out high sig markers and get pan-high marker score
SF7_Fc_high <- Ad_SF7_exprs_pdc %>%
select(one_of("CD11c", "Ly6C", "AF")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subset out low sig markers and get pan-low marker score
SF7_Fc_low <- Ad_SF7_exprs_pdc %>%
select(one_of("CD38", "MHC-II", "CD4", "B220")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subtract low values from high and normalize by total marker number (on a per cell basis)
high_low_dif <- (SF7_Fc_high - SF7_Fc_low)/7 #changed denominator
high_low_dif <- high_low_dif %>%
rownames_to_column('rn')
#rename score
names(high_low_dif)[2] <- "SLAMF7_score"
##---------Join SLAMF7_score back to main expression df---------
#Add SLAMF7 scores back to main expression df
Ad_SF7_fc_scored_pdc <- data.frame(colData(daf_X_pdc_SF7_Fc), t(assay(daf_X_pdc_SF7_Fc, "exprs")), check.names = FALSE) %>%
rownames_to_column('rn')
Ad_SF7_fc_scored_pdc <- left_join(Ad_SF7_fc_scored_pdc, high_low_dif, by = "rn")
summary(Ad_SF7_fc_scored_pdc$SLAMF7_score)
##---------now trying w/ Dr. Carlson's approach-------------##
#subset to pertinant data
diag_calc <- Ad_SF7_fc_scored_pdc %>%
select(one_of("SLAMF7", "SLAMF7_score")) %>%
as.data.frame(.)
#get quantiles
SF7q <- quantile(diag_calc$SLAMF7)
SF7_scoreq <- quantile(diag_calc$SLAMF7_score)
#Now plot the data and identify a line that passes through the lower left quantile intersection and the
#upper right quantile intersection. Then use the slope to identify parallel lines that pass through
#the upper left and lower right intersections:
diag <- lm(SF7q[c(2, 4)]~SF7_scoreq[c(2, 4)])
b <- coef(diag)[2]
a1 <- SF7q[4] - b * SF7_scoreq[2]
a2 <- SF7q[2] - b * SF7_scoreq[4]
#Now identify all points above and below the 2 diagonal lines
res1 <- diag_calc$SLAMF7 - (a1 + b * diag_calc$SLAMF7_score)
res2 <- (a2 + b * diag_calc$SLAMF7_score) - diag_calc$SLAMF7
idx <- ifelse(res1 > 0, 3, ifelse(res2 > 0, 2, 1))
#Get identification of outlier points
position <- c("neither", "activated", "blocked")
diag_calc$outlier <- position[idx]
diag_calc <- diag_calc %>% rownames_to_column('rn')
#remove SF7 and SF7_score so no redundancy when I join
diag_calc <- diag_calc %>%
select(., rn, outlier)
head(diag_calc)
#Join calls of outlier points back to main df
Ad_SF7_fc_scored_pdc_called <- left_join(Ad_SF7_fc_scored_pdc, diag_calc, by = "rn")
#Now plot (nicely) (WORKS BEAUTIFULY)
score_plot2 <- ggplot(Ad_SF7_fc_scored_pdc_called, aes(x=SLAMF7_score, y=SLAMF7, color = outlier, group = outlier)) +
geom_point(aes(size = outlier), alpha = 0.9) +
scale_size_manual(values=c(2,2,1.2)) + #change point sizes based on number of cells
scale_color_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
score_plot2 + theme(axis.line = element_line(linetype = "solid"),
axis.ticks = element_line(size = 0.9),
axis.title = element_text(size = 15),
axis.text = element_text(size = 14, colour = "black"),
axis.text.x = element_text(size = 14),
panel.background = element_rect(fill = NA))
#make pie chart of proportion of outlier calls
pdc_pred_pie <- table(
outlier = Ad_SF7_fc_scored_pdc_called$outlier,
condition = Ad_SF7_fc_scored_pdc_called$condition) %>%
as.data.frame(.)
ggplot(data=pdc_pred_pie, aes(x="", y=Freq, fill=outlier)) +
geom_bar(stat="identity", width = 1, color = "white") +
coord_polar("y", start = 0) +
theme_void() +
scale_fill_manual(values = c("#ff9900", "#9933ff", "#1a1a1a"))
pdc_pred_pie
sum(pdc_pred_pie$Freq)
##-----------------Now repeat for Monocytes--------------------##
#load the data
daf_X_clean <- readRDS(file = "./daf_X_clean.rds")
daf_X_mono <- filterSCE(daf_X_clean, cluster_id == "Monocytes", k = "merging1")
#---------------Get marker differences b/w KO (Ad-null) and WT (Ad-null)
#Subset to only KO
daf_X_mono_KO <- filterSCE(daf_X_mono, genotype == "SLAMF7_KO")
levels(daf_X_mono_KO$genotype)
KO_mono_med_mtx <- data.frame(colData(daf_X_mono_KO), t(assay(daf_X_mono_KO, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
KO_mono_med_mtx <- KO_mono_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_mono_KO <- KO_mono_med_mtx %>%
summarise_all(median)
#now WT
#Subset to only WT
daf_X_mono_WT <- filterSCE(daf_X_mono, genotype == "WT")
levels(daf_X_mono_WT$genotype)
WT_mono_med_mtx <- data.frame(colData(daf_X_mono_WT), t(assay(daf_X_mono_WT, "exprs")), check.names = FALSE)
#remove 1st 7 columns of metadata and SF7
WT_mono_med_mtx <- WT_mono_med_mtx %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#Get median expression values for all markers
mark_stats_mono_WT <- WT_mono_med_mtx %>%
summarise_all(median)
#I want the signature of what cell with SLAMF7 signaling looks like so I subtract KO values from WT values
mark_diff <- t(mark_stats_mono_WT-mark_stats_mono_KO) %>%
as.data.frame() %>%
arrange(., desc(V1)) %>%
rownames_to_column(., "markers")
##---------Get tam cell KO marker signature---------------
high <- mark_diff[1:5,] #top 5, but remove IgD
low <- mark_diff[21:25,]
SF7_KO_sig_mono <- bind_rows("up" = high, "down" = low, .id = "sign")
SF7_KO_sig_mono <- SF7_KO_sig_mono[-3,]
##---------Sum marker expression of sig markers in Ad-SF7-Fc monos cells and generate score---------
#subset to only Ad-Sf7-Fc group
daf_X_mono_SF7_Fc <- filterSCE(daf_X_mono, condition == "Ad_SLAMF7_Fc")
levels(daf_X_mono_SF7_Fc$condition)
Ad_SF7_exprs_mono <- data.frame(colData(daf_X_mono_SF7_Fc), t(assay(daf_X_mono_SF7_Fc, "exprs")), check.names = FALSE)
#clean up
Ad_SF7_exprs_mono <- Ad_SF7_exprs_mono %>%
select( -c("sample_id", "genotype", "response", "condition", "file_name", "sample_id.1", "cluster_id", "SLAMF7"))
#subset out high sig markers and get pan-high marker score
SF7_Fc_high <- Ad_SF7_exprs_mono %>%
select(one_of("CD11c", "Ly6C", "AF")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subset out low sig markers and get pan-low marker score
SF7_Fc_low <- Ad_SF7_exprs_mono %>%
select(one_of("CD38", "MHC-II", "CD4", "B220")) %>% #must edit here each time
transmute(sum = rowSums(across(where(is.numeric))))
#subtract low values from high and normalize by total marker number (on a per cell basis)
high_low_dif <- (SF7_Fc_high - SF7_Fc_low)/9 #changed denominator
high_low_dif <- high_low_dif %>%
rownames_to_column('rn')
#rename score
names(high_low_dif)[2] <- "SLAMF7_score"
##---------Join SLAMF7_score back to main expression df---------
#Add SLAMF7 scores back to main expression df
Ad_SF7_fc_scored_mono <- data.frame(colData(daf_X_mono_SF7_Fc), t(assay(daf_X_mono_SF7_Fc, "exprs")), check.names = FALSE) %>%
rownames_to_column('rn')
Ad_SF7_fc_scored_mono <- left_join(Ad_SF7_fc_scored_mono, high_low_dif, by = "rn")
summary(Ad_SF7_fc_scored_mono$SLAMF7_score)
##---------now trying w/ Dr. Carlson's approach-------------##
#subset to pertinant data
diag_calc <- Ad_SF7_fc_scored_mono %>%
select(one_of("SLAMF7", "SLAMF7_score")) %>%
as.data.frame(.)
#get quantiles
SF7q <- quantile(diag_calc$SLAMF7)
SF7_scoreq <- quantile(diag_calc$SLAMF7_score)
#Now plot the data and identify a line that passes through the lower left quantile intersection and the
#upper right quantile intersection. Then use the slope to identify parallel lines that pass through