peptide_pairwise_correlation: Peptide pairwise correlation or co-occurrence

Description Usage Arguments Value Author(s) See Also Examples

View source: R/peptide_pairwise_correlation.R

Description

perform correlation or co-occurrence analysis across all pairs of peptides. Pairwise comparison were implemented by to_pairwise.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
peptide_pairwise_correlation(
  d,
  analysis_type = "correlation",
  perform_test = FALSE,
  cor_method = "pearson",
  occ_method = "jaccard",
  occ_test = "fisher",
  p_adjust_method = "fdr",
  hit_threshold = 1,
  temporal_samples = FALSE,
  si = NULL,
  output_str = "data.table",
  mc = 1
)

Arguments

d

a data frame or tibble containing z-scores or binary indicator of peptide enrichment. Columns represent peptides and rows represent samples. Column names are peptide ids and row names are sample ids.

analysis_type

type of analysis to perform. Options: "correlation" or "cooccurrence". If select "correlation", correlation will be calculated on the z-scores, and cor_method will be used. If select "cooccurrence", z-score will be converted to a binary indicator of enrichment (1/0), and occ_method and occ_test will be used. Default: correlation

perform_test

a logical indicator of whether statistical tests should be performed for each comparison. The test method is specified by cor_method and occ_method, depending on analysis_type. Default: FALSE

cor_method

correlation coefficient and test to be computed. Pass to cor and cor.test Options: "pearson", "spearman", "kendall". Default: "pearson"

occ_method

cooccurrence coefficient to be computed. Pass to peptide_cooccurrence. Options: "jaccard", "phi", "prop", or any combination of them in a vector. Default: "jaccard"

occ_test

cooccurrence tests to be computed. Pass to peptide_cooccurrence. Options: "fisher" (Fisher's exact test) or "chisq" (Pearson's Chi-squared test). Default: "fisher"

p_adjust_method

method to adjust p values for multiple comparison. Pass to p.adjust. options: "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none". Default: "fdr"

hit_threshold

the antibody reactivity threshold above which the epitope is considered as enriched. Default: 1

temporal_samples

a logical indicator of whether there are multiple temporal samples from each individual. If TRUE, an additional data frame si is needed to indicate the attribution of samples to individuals. To account for the temporal structure, z-score difference between each two consecutive temporal points will be calculated and used for the correlation analysis. Although the function tolerates cooccurrence analysis with temporal samples, it is not preferred as changes of binary status are less informative. To perform cooccurrence analysis, only the change from 0 to 1 between two time points is considered as 1 in the difference data. Default: FALSE

si

a data frame or tibble indicating the temporal structure of the samples. The first column of si is the sample id, which should match the row names of d. The second column of si is the individual id. All other columns will be ignored.

output_str

format of the output to return. Options: "data.table", "data.frame", and "tibble". Default: "data.table"

mc

number of cores to use for multi-thread parallel analysis. Pass to mclapply. Deafult: 1

Value

a data frame/data table/tibble that contains correlation or co-occurence analysis results of all pairs of peptides

Author(s)

Siyang Xia sxia@hsph.harvard.edu

See Also

peptide_coocurrence, to_pairwise

Examples

 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
data(peptide_z)
sample_info <- data.frame(id = row.names(peptide_z),
                          individual = rep(c("ind1", "ind2"), each = 6))

### 1. correlation analysis with default setting
output1 <- peptide_pairwise_correlation(d = peptide_z)
head(output1)

### 2. correlation with statistical tests
output2 <- peptide_pairwise_correlation(d = peptide_z,
                                        si = sample_info,
                                        analysis_type = "correlation",
                                        perform_test = TRUE,
                                        cor_method = "pearson")
head(output2)

### 3. correlation with temporal samples
output3 <- peptide_pairwise_correlation(d = peptide_z,
                                        si = sample_info,
                                        analysis_type = "correlation",
                                        perform_test = TRUE,
                                        cor_method = "pearson",
                                        temporal_samples = TRUE)
head(output3)

### 4. cooccurrence analysis with all three coefficients
output4 <- peptide_pairwise_correlation(d = peptide_z,
                                        si = sample_info,
                                        analysis_type = "cooccurrence",
                                        hit_threshold = 5,
                                        perform_test = FALSE,
                                        occ_method = c("jaccard", "phi", "prop"),
                                        temporal_samples = FALSE)
head(output4)

### 5. cooccurrence analysis with two coefficients and fisher's exact test
output5 <- peptide_pairwise_correlation(d = peptide_z,
                                        si = sample_info,
                                        analysis_type = "cooccurrence",
                                        hit_threshold = 10,
                                        perform_test = TRUE,
                                        occ_method = c("jaccard", "phi"),
                                        occ_test = "fisher",
                                        temporal_samples = FALSE)
head(output5)

### 6. cooccurrence analysis with only phi coefficient and return as a tibble
output6 <- peptide_pairwise_correlation(d = peptide_z,
                                        si = sample_info,
                                        analysis_type = "cooccurrence",
                                        hit_threshold = 5,
                                        perform_test = FALSE,
                                        occ_method = "phi",
                                        temporal_samples = FALSE,
                                        output_str = "tibble")
head(output6)

siyangxia419/virlink documentation built on Jan. 2, 2022, 12:16 a.m.