{'fraction_non_alphanumeric': 0.030111750128582783, 'fraction_numerical': 0.011315284986206575, 'mean_word_length': 4.5682114032803955, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Measure of Strength of Evidence for Visually Observed Differences between Subpopulations

An increasingly important data analytic challenge is understanding the relationships between subpopulations. Various visualization methods that provide many useful insights into those relationships are popular, especially in bioinformatics. This paper proposes a novel and rigorous approach to quantifying subpopulation relationships called the Population Difference Criterion (PDC). PDC is simultaneously a quantitative and visual approach to showing separation of subpopulations. It uses subpopulation centers, the respective variation about those centers and the relative subpopulation sizes. This is accomplished by drawing motivation for the PDC from classical permutation based hypothesis testing, while taking that type of idea into non-standard conceptual territory. In particular, the domain of very small P values is seen to seem to provide useful comparisons of data sets. Simulated permutation variation is carefully investigated, and we found that a balanced permutation approach is more informative in high signal (i.e large subpopulation difference) contexts, than conventional approaches based on all permutations. This result is quite surprising in view of related work done in low signal contexts, which came to the opposite conclusion. This issue is resolved by the proposal of an appropriate adjustment. Permutation variation is also quantified by a proposed bootstrap confidence interval, and demonstrated to be useful in understanding subpopulation relationships with cancer data.


Introduction
In the age of Big Data, many contexts involve analyzing and understanding relationships between multiple subpopulations. A fascinating and particularly deep example of this comes from cancer research as illustrated in Section 1.1, where we have gene expression data from five cancer types and a goal of understanding relationships between the cancer types (aka sub population). A common approach to understanding subpopulation differences is visualization using Principal Component Analysis (PCA) Jolliffe (1986). While this method gives useful insights, visual approaches can be deceptive. This motivates our work to develop a method for quantification of the strength of the evidence for distinction between each pair of groups. Because of the very rich general structure of biological processes, classical statistical distributional models are woefully inadequate due to many uninterpretable low p-values. Hence permutation testing methods provide an appealing alternative. Here we take the null hypothesis to be that the subpopulations are exchangeable, and study testing procedures that are particularly powerful against alternatives with different means.
Cancer data is frequently high signal, meaning there are usually very strong differences between subpopulations. A consequence of high signal data is that the comparison of strength of subpopulation differences across multiple subtypes cannot be done using classical p-values. This point is illustrated in Section 1.1 for the DiProPerm method proposed by Wei et al. (2016). As seen there, that method measures strength of difference between two subpopulations by projecting the data onto a direction aimed at separating them, and summarizing using the difference of the projected means as a statistic. Typical permutation p-values are calculated using the number of permuted summaries that lie outside the corresponding true data summary statistic. The challenge of high signal situations is that there frequently are no permuted statistics outside that range, so the only conclusion is that the permutation p-value is < 1 n P where n P is the number of permutations. While such a conclusion of strongly rejecting the null hypothesis is fine for a single hypothesis test It is inadequate for comparing the strength of differences across several pairs of subpopulations. In particular, because that number depends only on the number of permutations, it is of little use for meaningful comparisons over multiple sub-populations, as done in Section 1.1.
This motivates our invention of the Population Difference Criterion (PDC), which is a quantitative measure of separation between subpopulations that provides meaningful comparisons even in high dimensional and high signal contexts. Details of the PDC are introduced in the context of a real example in Section 1.1.
Another major contribution of this paper discussed Section 2 is a careful theoretical study of a peculiar phenomena when increasing signal to noise ratio leads to loss of statistical power as measured by the PDC. We show that this issue can be addressed by using non-standard permutation scheme in computation of PDC, see Figure 8.

Illustration of PDC using Cancer Data
A fascinating and particularly deep example motivating subpopulation comparisons is the Pan-Cancer gene expression data (Hoadley et al. (2018) (TCGA) Hutter and Zenklusen (2018). Here, we used a subset of the TCGA Pan-Cancer data representing 1523 cases from 5 cancer types including 12478 genes (shown in Figure 1). The tissues came from different organs (hence different cancer types), and represent a useful cohort to illustrate our proposed method for quantitatively determining their level of similarity or dissimilarity. To demonstrate the proposed method, we select a broad range of five different cancer types, one of which has a gene expression pattern that is very different from the rest and two of which are similar to each other. These cancer types are contrasted in visualizations using the colors and symbols shown in Table 1.1. Figure 1 shows the relationship between cancer types using a PCA scatter plot. Figure 1 displays the two-dimensional projection of the point cloud in R 12478 onto the two directions of highest variation. The PC1 scores are plotted on the vertical axis and the PC2 scores on the horizontal axis. LAML (magenta), a liquid tumor, is very different from the rest, which are solid epithelial tumors. Within the epithelial tumors, READ (red) and COAD (yellow) appear visually quite overlapped, consistent with the fact that these cells come from organs in the same developmental process and often referred to as a single disease (colorectal cancer). The BLCA (blue) and BRCA (cyan) are somewhat different but not as separated as BLCA and LAML.
In Figure 1, PCA clearly shows the relationships between subpopulations. However, it is important to keep in mind that it is driven by directions of maximal variation, which are not necessarily the same as directions that clearly distinguish subpopulations. A particularly useful direction for distinguishing subpopulations is the Distance Weighted Discrimination (DWD) direction vector proposed by Marron et al. (2007). That method was originally developed as an improvement of the Support Vector Machine (SVM) (Cortes and Vapnik, 1995) classification method in high dimensions. In addition to improved classification performance, DWD also provides unusually good visual separation of subpopulations projected on the DWD direction because it avoids data piling issues (too many data points  Table 1.1. As biologically expected LAML is much different from the rest and COAD and READ overlap in PCA space. having a common projection) that is endemic to the SVM in high dimensions as discussed in Marron et al. (2007).
While DWD is quite effective in the visual separation of subpopulations, it is based on complex optimization and its original implementation could be relatively slow to compute. This problem has been partially mitigated in the case of large sample sizes by the algorithm of Lam et al. (2018). However, DWD can still be slow within the context of permutation methods such as DiProPerm due to repeated calls. Therefore, we will also investigate a computationally faster approach based on projection on the Mean Difference (MD) direction, i.e. the direction pointing from the mean of one group to the mean of the other.
Each panel of Figure 2 shows the one dimensional projection scores onto MD directions in the top row and corresponding DWD directions in the bottom row as colored symbols for pairwise comparisons of subpopulations. Scores are shown in each panel using a jitter plot (Tukey (1976)) where on the horizontal axis we plot the coefficient of projection on the MD and DWD direction respectively and the vertical axis is a random height for visual separation. The black curves are kernel density estimates (KDE, i.e., a smooth histogram, Wand and Jones (1994)) of the whole population. Subdensities, corresponding to each subpopulation, are shown using colors that correspond to the symbols. The numbers on the vertical axis are the height of the kernel density estimate. In each panel, there is better visual separation of the subpopulations for DWD (bottom) then for MD (top). The subpopulations are better separated using DWD because the particular optimization problem that it solves is preferable for studying subpopulation differences. However, MD is much faster to compute, and is more amenable to rigorous mathematical analysis. Figure 2 shows broadly similar lessons to Figure 1: READ and COAD are rather overlapped (left panels); BRCA and BLCA are moderately different (middle panels) while LAML is very distinct from BLCA (right panels). While such graphics are suggestive, they can be deceptive. As noted in Wei et al. (2016), rigorous quantification of visual differences can be surprisingly counter intuitive, because human intuition is not good at incorporating issues such as sample size and high dimensional variation into visual impression. An explicit example of this is shown in Figure 2.3 of the PhD dissertation of Yang (2021). Hence it is very important to provide a quantitative measure of the strength of the evidence for visual subpopulations separation based on rigorous statistical inference.
Early version of a quantitative measure of this type was provided by the DiProPerm test (Wei et al. (2016)). Figure 3 shows the DiProPerm test results for the three pairs: READ vs. COAD; BLCA vs. BRCA; LAML vs. BLCA. While separation of labeled classes can be measured in a number of ways, in this paper we focus on measures that are meaningful in the context of PCA-like plots. In particular, we use the difference of sample means of the projections coefficients on the separating direction for each subpopulations. Detailed reasons for this choice can be found in Wei et al. (2016). For each of the comparisons in Figure 2, the value of this difference is displayed numerically in blue in Figure 3 and, when that number is within the range of the horizontal axis, it is also shown by a vertical blue line. Statistical significance is assessed using a permutations based null distribution. For each permutation of the data, the separating direction is recomputed and the permuted subpopulations are re-projected on the recomputed separating direction. The difference of means of the projection coefficients are shown as black stars in each panel of Figure 3. Note that in almost every case, the permuted separations are much smaller than the blue population difference of sample means indicating a statistically significant difference. Because there are 100 permutations, this is consistent with an empirical p-value of less than 0.01 in a classical permutation test. Figure 3 shows a serious challenge: in bioinformatics applications the actual population projected difference (vertical blue line) can often be much larger than all of the permuted differences, leaving comparisons based on permutation p-values ineffective. In principle, one could simulate more permutations, but the number needed to effectively compare very large differences will be prohibitive.
Population Difference Criterion (PDC) is a quantitative measure of the widely varying differences between subpopulations that are visually apparent in Figures 1 and 2. As explained above, instead of using permutation p-values, i.e., counting black stars to the right of the blue line in Figure 3, strength of subpopulation difference is measured in the number of standard deviations the test statistic (blue line) is from the center of the null distribution (black stars). Specifically, let C be the observed test statistic, andC and S be the sample mean and sample standard deviation of the null distribution (black stars). Then PDC is Larger values of PDC represent stronger evidence of the difference between subpopulations. Note that if the null distribution was Gaussian, the PDC would be the classical Z-score and was called that in Wei et al. (2016). But that term is not used here to keep it clear these that distributions could be far from Gaussian. An interesting aside is that (as illustrated in Figure 3) PDC is useful in domains that are quite different from that of classical hypothesis testing, where the goal is to simply accept or reject the null hypothesis. In particular, momentarily thinking of the PDC in terms of Gaussian approximations, many of the corresponding p-values for the examples in Figure 3 would be far smaller than the general floating point precision. From the latter viewpoint, there is strong evidence that all differences are significant, and that is the end of the story. However, understanding the relationship between subpopulations is a different challenge that is addressed by PDC. A very important example of the value of PDC is in comparison of the many possible pre-processing operations that are routinely used in bioinformatics applications. In particular, better pre-processing methods are those which result in larger PDC for a given set of subpopulations of interest.
The top right panel of Figure 3 reveals an unattractive aspect of the original version of DiProPerm based on conventional permutations (Wei et al., 2016) which is that the null DiProPerm distribution (black stars) are very skewed to the right impacting the PDC in a negative way. As one of the major contribution of this paper we propose to replace the use of conventional permutations with balanced permutations, see Section 2.4 for details. The null distribution computed using balanced permutation is shown as red stars in all panels of Figure 3 and so is the corresponding numerical PDC value. In most cases the PDC using the balanced permutations is substantially larger than the PDC using conventional permutation of Wei et al. (2016) indicating often large increases in power.
There are a few interesting aspects of the results in Figure 3. PDC based on DWD provides substantial improvement over PDC based on MD. As visually expected COAD vs. READ has the lowest PDC for balanced and all permutations, and BLCA vs. LAML has the highest PDC for balanced permutations. A noteworthy discrepancy is that the PDC based on MD and all permutations for BLCA vs. LAML is lower than the corresponding PDC for BRCA vs BLCA. This apparent contradiction is resolved using balanced permutations. The balanced permutations only increase the PDC by a small amount for the left panels because when the signal is small, the balanced permutations have minor or no influence on the PDC. The increase is substantial for right panels because when signal is large, the balanced permutations provided a large increase in the power of the PDC.
Sections 2 and 3 contain mathematical analysis of the above phenomena. Most of the theoretical analysis is concerned with the MD direction using closed form expressions. The theoretical analysis clearly demonstrates why balanced permutations are superior to all permutations. The theoretical representation for DWD is more challenging so we rely on simulation results in that case.
The above recommendation of balanced permutations in the case of PDC is somewhat opposite to a parallel recommendation against balanced permutations in the case of p-values (Southworth et al., 2009). They appeal to group theory and suggest that all permutations are generally superior to balanced permutations since balanced permutations tend to be anti-conservative. Hemerik and Goeman (2018) provided adjustments that make the use of balanced permutations for p-value calculation possible. In Section 3, we study the impact of these ideas on PDC. A minor contribution of our paper is that the theoretical analysis provides another adjustment to balanced permutation PDC that overcomes the anti-conservative problem.
When computing PDC, one typically samples a relatively small number of permutations. Yet another contribution of this paper appears in Section 4, where we propose confidence intervals that account for the Monte Carlo uncertainty. The proposed methodology is demonstrated by studying a real data example in Section 5.

Large Signals Lead to the Loss of Power
In this section, we first investigate the surprising behavior that stronger signals can lead to smaller conventional DiProperm PDCs using a simulated example in Section 2.1. This surprising behavior is explained with a appropriate mathematical analysis for the MD direction in Sections 2.2 and 2.3. This motivates the balanced permutation modification of DiProPerm that discussed in detail in Section 2.4.

Simulation study
In this section, we study the behavior of the DiProPerm PDC using a Gaussian model. Both classes are assumed to follow the normal distribution with means shifted by 2g, i.e.
Class +1 (X) : Figure 4 shows realizations, based on all permutations, of the PDC (colored circles) for different choices of d and g, with colors representing d. The vertical axis shows the DiProPerm PDC, where each circle is a single realization from an equally spaced grid of 200 g s between 0 and 20. When using the MD direction and d > 1 (left panel), the PDC first goes up (as expected from increasing signal strength) and then goes down (which is quite surprising). When using the DWD direction, there is no actual decrease yet the PDC tends to level off instead of increasing, as expected, with increasing signal strength. This surprising behavior in power is explained using careful investigation in Sections 2.2 and 2.3 for the MD direction. The general tendency in these point clouds is reflected by the dashed curves in the left, whose formulas are derived from the underlying probability distributions in Sections 2.2 and 2.3. DiProPerm using the DWD direction is based on a complex optimization process, while the computation of MD is more straightforward. Thus, we will use the MD direction to explain the surprising pattern of the PDCs with respect to signal strength in the following paragraph. As shown in the left panel of Figure 4, this behavior is strongest for the red circles d = 100, which will be explained by studying the DiProPerm permutation distributions. In Figure 5, the 3 columns correspond to the three cases shown using stars in Figure 4. The top three panels of Figure 5 are similar to the right panels in Figure 3. These 3 panels show the simulated realization of the mean differences shown as the colored dots: C i , i = 1, ..., N (i is the index of the permutation and usually N = 100 or 1000) and their kernel density estimates for d = 100, g = 2, 4, 20 (highlighted as black stars in Figure 4). Recall these 3 values of g represent increasing, peak, and decreasing regions of PDCs for d = 100. From left to right, the kernel density estimates become more skewed and multi-modal. The right panel is severely multi-modal. The modes are generated by different means of the permuted subgroup, which are caused by different proportions of the subgroups in the permuted sample. These proportions are quantified by the coefficient of unbalance ξ i as defined in (4) in Section 2.3. The colors of the dots in these 3 top panels represent the absolute value of ξ i of the ith permutation, using the color bar shown in Figure 6. As the signal, g, gets stronger there is much more separation of colors based on |ξ i |. In the top left panel, which has the smallest signal (g = 2), the colored dots are mostly mixed. In the top middle panel, as the signal strength (g = 4) increases, the colored dots separate more. In the right panel, the dots around each peak have a different color showing a strong mixture distribution pattern and separation according to the value of |ξ i |. In particular, in the top right panel, the C i with smaller |ξ i | tend to appear on the left side, while larger ones appear on the right side.
The strong multimodality is explained in the bottom two rows which show the projections on the permuted directions for the smallest and largest C i . In each case, the symbols represent the original class labels and the colors show the permuted labels, whose mean difference determines the direction. Each panel of the middle row shows the permutation with maximal C i for that d and g. These permutations with the maximal C i represent the far-right colored circles in each top panel. Going from left to right, the permuted mean difference direction first separates the red/blue permuted class colors and then tends to separate the symbols (the original class labels). This direction essentially becomes the original mean difference direction of the non-permuted data for large g. This effect is usefully quantified by the angles between the observed mean difference and each permutation direction shown in each panel in the middle row. A large angle suggests a large discrepancy between the original mean difference and the corresponding permutation direction. The left panel g = 2 is separating the colors well and mixing up the symbols as intuitively expected from the permutation test, with a relatively large angle, 56 • . This results in a PDC reflecting no signal as expected from the permutation test. In the middle g = 4 panel, there is still some color separation but also a strong separation of the symbols, with a smaller angle, 33 • . This results in the unbalance generating a larger than expected PDC. In the right g = 20 panel, the angle is very small, 8 • , showing this direction is very close to the mean difference direction of the original data. Because of the true class difference and the large unbalance, this results a much larger than expected PDC as shown in the top right panel. In particular, these values of PDC do a very poor job of reflecting the desired null distribution of no signal which results in a strong loss of power. This problem will be addressed using a balanced permutations. Indeed, for large g, the value of C i strongly feels the corresponding unbalance of |ξ i |. In particular, the stronger the unbalance the larger the |ξ i |.
The bottom three panels of Figure 5 show the projections of C i of the far left point. They are represented as the far left colored stars in the top panels.
However, because |ξ i | ≈ 0, the large g doesn't so strongly dominate the nearly balanced permutations as seen in the bottom panels, where the angles are relatively large and close to 90 • (82 • , 79 • , 88 • ) as expected for random directions from the results of Hall et al. (2005). Hence the bottom panels show projections which are much more consistent with the null hypothesis of no signal. This motivates restricting the DiProPerm to use only balanced permutations, i.e. red dots, which will give a null distribution much closer to the actual null as proposed in Section 2.4.

Observed Statistics
An important component of our mathematical analysis is the derivation of the distribution of the observed statistics under the model (1). As described in Section 1, DiProPerm is based on the observed mean difference of projected score, C, shown using blue text in Figure 3. Under the model (1) in Section 2.1, using the MD direction ) and so ).
Here χ d (λ) is called the non-central Chi distribution (Johnson et al., 1972), because it is the square root of the non-central Chi square distribution with degrees of freedom d and non-centrality parameter λ 2 . Note that where L a n (z) is the generalized Laguerre polynomial (Koekoek and Meijer, 1993). Then we have ).
(2) Figure 5: DiProPerm permutation results (according to (1)) for d=100. Left: g = 2; middle: g = 4; right: g = 20 (these realizations generate these three cases shown as black stars in Figure 4). Top panels are the permuted statistics C i and their kernel density estimates, the PDCs are indicated in green text; middle and bottom panels are chosen permutations with colors representing the permuted labels and symbols representing the original labels; the middle row of panels have the largest permuted statistic (highlighted as the colored circles in the top panels); bottom panels are permutations with the smallest permuted statistic (highlighted as the colored stars (*) in the top panels). These explain the increasing skewness in the top panels as g grows. Figure 6: Colorbar used in the jitter plots in the top panels in Figure 5. Numbers represent the absolute value of the coefficient of unbalance ξ i defined in Section 2.3.

Permutation distribution
Let C i = ||X per −Ȳ per ||, i = 1, · · · , N (for a number of random permutations N ) be the realizations of the permutation distribution of the test statistics, i.e. the black stars in Figure 3. For each permutation i = 1, · · · , N, there is a random number R i of observations in each class that switch labels. Note that R i is a Hypergeometric random variable whose probability mass function is: The conditional distribution ofX per −Ȳ per is (detailed derivation shown in the Appendix A): Thus, R i m is the proportion of the original Class -1 cases that are relabeled as the permuted Class +1, and n−R i n is the proportion of the Class -1 cases that remain in the new Class -1. The difference between these 2 proportions, denoted as reflects the class unbalance of this permutation. Hence we call it the coefficient of unbalance. When ξ i = 0, the mean of the null permutation distribution is canceled and we call this kind of permutation a balanced permutation, e.g. the red dots in the top panels of Figure 5. Define and λ r = 4g 2 r σ 2 ( 1 m + 1 n ) , then the unconditional distribution ofX per −Ȳ per is a normal mixture which is related to Theorem 1 in Wei et al. (2016): The permutation null distribution is Then we have From the above equations, the sample sizes m, n are inversely related to the sample variances. This is consistent with the middle panels of Figure 3 that BRCA has a very large sample size and hence the variances of the red/black stars are relatively small. The expectation of the PDC= C−C S is hard to calculate, so we consider the following surrogate using (2), (8), (9): As shown in Figure 4, f (m, n, d, g) (for fixed m, n) provides a reasonable approximation of the center of the point cloud of simulated PDCs, which indicates the usefulness of this as a central curve. The f (m, n, d, g), dashed curves in Figure 4, show a very clear pattern for each d, the PDC first increases and then goes down apparently to some constant. Fro the reasons shown in Section 2.2, the value of this constant is calculated in the Appendices B:

DiProPerm with Balanced Permutations
The calculations of Section 2.2 motivate a major improvement in DiProPerm by using only the balanced permutations. A permutation is called balanced if ξ i = 1 − R i × (1/m + 1/n) ≈ 0. Consequently the number of switches in labels is equal to mn m+n . If the data is generated using the alternative hypothesis, g is much bigger than 0. Using only the balanced permutations makes the mean of the permutation distribution closer to zero. Therefore, it provides a more useful alternative distribution. Figure 7 shows a simple example illustrating balanced and unbalanced permutations. There are 8 cases in each class shown as rows. The first row is colored using the real class labels followed by 7 permutations where symbols represent the true class labels and colors represent the permuted class labels as in the bottom 6 panels of Figure 5. The colors of the text on the right are in the spirit of the color bar in Figure 6 and the colored dots in the top panels in Figure 5 which gives the curve as: For small g in both panels of Figure 8, the balanced and unbalanced PDCs overlap. When the signal reaches a certain level, the balanced PDCs continue increasing as expected (from the increased signal strength), and the unbalanced PDCs reach a peak and then seem to decrease (MD) or stay as some constant (DWD). This indicates the balanced PDC is much more powerful than the unbalanced PDC in the case of strong signals for both MD and DWD directions. A careful look at the axis labels show that stronger signals are required to see this effect for DWD cases.  Southworth et al. (2009) show that balanced permutations tend to give anti-conservative test results, i.e. their reported p-values are too small, they suggest this is caused by the balanced permutation scheme not having a group structure. In particular, under their null hypothesis, the permutation distribution, e.g. distribution of the red circles in Figure 3 doesn't have enough extremely large values. This is not directly relevant to our analysis, because we are comparing the two distributions using PDCs and not the p-values. Figure 4 reveals the strange behavior that under the alternative the power of the tests from all permutations decreases as the signal strength increases. The much improved power of balanced permutations is shown in Figure 8 which again essentially added the corresponding balanced permutations to Figure 4. Note that the balanced permutation power is proportional to the signal strength. When the signal is weak, Figure 8 and the top right panel of Figure 3 show that the balanced and unbalanced permutations are very similar (especially the PDCs). Thus, in the context we are studying, balanced permutations are superior to all permutations in large-signal cases which often arise in bioinformatics contexts and have no or minor differences from all permutations in small-signal cases.

Correlation Adjustment
We use permutation to simulate the null distributions shown as the black and red curves in the right panels in Figure 3. Recall that the PDC is defined as C−C S . The sample meanC is an unbiased estimate of the mean of the null distribution, but the sample standard deviation is not similarly unbiased. Due to their dependence on the observed data, the black/red circles are positively correlated. This leads to an anti-conservative PDC which is similar in spirit to the related phenomena for p-values that was first reported in Southworth et al. (2009). Here, we explicitly calculate the correlation, show that it is usually very small, and use it to propose an adjustment to the current PDC. An alternative adjustment to p-values has been developed in Hemerik and Goeman (2018).
Under the setting of Section 2.1 with g = 0, let us first consider m = n. As defined in Section 2.3, R i is the number of observations in each class that switch labels in permutation i. Here we only give the derivation from all permutations (a similar derivation for balanced permutations can be seen in the Appendix C) . Let {X j |j ∈ J R i } be the cases in the original class +1 that are labeled as -1 and {Y k |k ∈ K R i } be the cases in the original class -1 that are switched to +1 in permutation i. Let √ M 0 be the difference of the class means of the non-permuted data (R 0 = 0) and let √ M i be that of permutation i. Thus Using a similar derivation to that in Section 2.2, both M 0 and M i follow 2 n σ 2 χ 2 d (0). The correlation between them is (see the Appendix C for detailed derivation): As d → ∞, and by the delta method, In order to get the correlation between the mean differences from two random permutations, we add up the weighted correlations (the additive property applies due to this special setting, see the appendices for more details). For all permutations: Using a similar derivation, the correlation between two random balanced permutations is: n/2 k 1 n/2 n/2−k 1 n n/2 n/2 k 2 n/2 n/2−k 2 n n/2 In the left panel of Figure 9, we compare the theoretical correlations for balanced permutations (blue): r bal,∞ = 1 2n−2 and for all permutations (red): r all,∞ = 1 2n−1 as functions of n. The blue is always larger than the red showing that the balanced permutations have larger correlations than all permutations. Those correlations are all very small and decrease rapidly with n. When n > 50, the difference between them is quite negligible and the correlations will decrease as n goes to infinity with a limit of zero.
The right panel of Figure 9 is a zoomed in view to investigate the difference between correlations for d = 1, 2, ∞. The curves are all differences of correlations from balanced permutations when d = ∞, i.e. differences from r bal,∞ . All curves are smaller than or equal to zero indicating that r bal,∞ is the correlation upper bound. In particular, Figure 9 shows that r bal,∞ ≥ r bal,2 ≥ r bal,1 and r bal,∞ ≥ r all,∞ ≥ r all,2 ≥ r all,1 .
The dotted magenta curve is the smallest which indicates that the correlation for all permutations with d = 1 (r all,1 ) is the smallest. For each color, magenta, and green, the solid These curves (decreasing rapidly) are very close to each other and r bal,∞ > r all,∞ . The right panel enables a more detailed study for d = 1, 2 in both cases, showing the difference between these correlations and the upper bound r all,∞ . Correlations rapidly decrease as a function of n and increase slightly as a function of d. When d = 1, 2, correlations are already very close to the limit d = ∞, which is also the upper bound.
curves are larger than the dotted and the dashed are larger than the solid. This suggests that correlations will increase when d increases for both balanced and all permutations. As n becomes large, all curves are close to each other, indicating the correlations all become similar and very small.
In the case of m = n, similar results hold Corr a . In particular, similar calculations show Corr b are close to each other, but the all permutations correlation is always less than that for balanced permutations: The sample variance S 2 , correlation and variance are related by: Thus instead of the original DiProPerm PDC: C−C S , we propose (C−C) √ 1−Corr S as the adjusted PDC. From here on, we will use the adjusted PDC in this paper. This adjustment makes very little difference unless the sample size is very small.

Quantification of Permutation Sample Variation
While they provide useful comparisons between data sets, the p-values and the PDCs inherit variation from random sampling among the full set of permutations. In some cases, this variation can obscure important differences between classes which motivates careful quantification of this uncertainty.

Confidence Intervals
One conventional method for confidence interval calculation is based on simple simulation to approximate the underlying distribution. This solution requires multiple DiProPerm tests which can be computationally expensive. This motivates the development of an efficient way to evaluate the variation of the DiProPerm test PDC.
In Section 1, The PDC is calculated as C−C S . Consequently, the PDC is also a random variable that depends on the permutation null distribution, from which the N , i.e. N = 100 or 1000, black stars were drawn. Thus, a confidence interval for the PDC can be estimated by the upper and lower quantiles using bootstrap simulation/sampling methods. A general algorithm is based on B repetitions (B = 100 or 1000): 1. Draw a B × N matrix where each row is a random sample (with replacement) from the black stars. Calculate the sample means and variances of each row. This results in B sample means and variances, which are used to get B sampled PDCs.

Find the upper and lower quantile of the PDCs based on the B sampled PDCs in
Step 2.
A similar method can be developed to estimate confidence intervals for the p-value. However, as stated above, p-values are often too small to show up in the simulation quantiles. Thus, the PDC is more informative for comparison of the significance across such settings.
Note that this method is unrelated to the direction choices of DiProPerm and thus it can be applied for any direction such as MD, DWD, SVM, etc. Alternatively, as we discussed in Section 2.3 when the original data are close to normal, the distribution of the black stars is close to the χ distribution. Thus, we can also estimate the distribution using the method of moments estimation based on the Welch-Satterthwaite approximation (Satterthwaite (1946)). However, in practice, the normal assumption of the original data is often violated, and the bootstrap resampling method works well without any assumption and gives high efficiency.

TCGA Pan-Can Data
In this section, we apply our improved DiProPerm test to the 5 types of cancer from TCGA Pan-Can data (Hoadley et al. (2018)) studied in Figure 1.
For all 10 pairwise TCGA cancer type hypothesis comparisons, Figure 10 gives a comparison of the strength of separation using the PDC. The random permutation variability in estimating each PDC is reflected by a 95% confidence interval as developed in Section 4.1. Conventional single-sample confidence intervals are shown as thick lines, proper simultaneous inference comes from considering the thin lines which are Bonferroni adjusted for the fact that we have 10 intervals here. The results based on MD are shown in black/gray and results based on DWD are shown in blue/light blue. The PDCs are not the centers of the confidence intervals because the distributions of the permutation statistics, e.g. black/red circles in Figure 3, are skewed. The PDCs computed using balanced permutations (circles) are much higher than the PDCs computed using all permutations (stars) showing the strong value of balanced permutations. Overall DWD based PDC (blue) is relatively higher than MD (black) showing the utility of DWD over MD for visualizing class differences in higher dimensions and the benefits of balanced sampling.
In Figure 10, LAML vs. BRCA has the largest PDC and all pairs involving LAML tend to have large PDCs. This is consistent with Figure 1 which shows that LAML (magenta) is the most distinct cancer type. Other pairs including BRCA such as BRCA vs. COAD also have relatively large PDCs. This is consistent with the fact that BRCA has the largest sample size which leads to a smaller variance and thus stronger statistical significance. The PDCs for LAML vs. READ and LAML vs. BLCA and BRCA vs. COAD reflect similar amounts of population difference. The PDC allows us to accurately quantify the strength of population difference in each pair. The confidence intervals allow us to statistically assess if there is difference in these strengths of population difference across pairs. In particular, the overlap of their confidence intervals shows no statistically significant difference across these pairs. Other overlapped confidence intervals also indicate the relative differences between those populations are similar. Figure 10: DiProPerm 95% confidence intervals for all 10 pairwise tests of 5 types of cancers from TCGA data. The thicker lines represent individual confidence intervals for each test and the thinner lines are the multiple test confidence intervals using Bonferroni correction. The circles indicate the PDCs from balanced permutations and stars indicate all permutations. The DWD based PDCs are shown in blue/light blue and MD based PDCs are shown in black/gray. The test statistic is also shown in the top of each bar. The LAML tumors are very different from other cancer types which is consistent with the visual impression in Figure 1.
In cases with a strong signal, such as LAML vs. BRCA, LAML vs. COAD and BRCA vs. COAD, the balanced PDCs (gray/blue circles) give much stronger performance than the corresponding PDCs computed using all permutations (gray/blue stars). This is consistent with the idea that when the signal is strong, all permutations will cause a loss of power (shown in Figures 4 and 8) as PDCs from all permutations are significantly smaller than balanced PDCs. When the signal is weak, such as COAD vs. READ (as shown in Figure 1 where COAD and READ are overlapped), the unbalanced and the balanced PDCs are small and similar to each other. Those PDCs are the smallest among all test pairs indicating the weakest difference among the considered comparisons as shown in Figure 10. This is consistent with Figure 1 where COAD (yellow) and READ (red) are overlapped in the PC1 and PC2 directions.

Appendices A Conditional Distribution ofX per −Ȳ per
Under the assumptions in Section 2.1, if we pick r cases from each class to switch labels, In this scheme, there are m r n n−r permutations out of m+n m overall random permutations. Thus, the probability of picking r cases from each class to switch labels is ( m r )( n n−r ) ( m+n m ) .

B Limit distribution
In this section, we calculate the all permutations (dashed) and balanced permutations (solid) curves in Figure 8 as functions of m, n, d, g, i.e. use f (m, n, d, For balanced permutations, fix r = mn m+n . Similarly as in Section 2.3, C i ∼ σ 1 m + 1 n χ d . Thus,

B.2 All Permutations
In the unbalanced case, ∀d, the limit (as g → ∞) of the permuted MD distribution is the same as the observed MD distribution, which is consistent with what we observed in Figure 4. This implies the limit distributions of the C i (or C) are the same ∀d in the unbalanced cases. Thus the limit distributions of the PDC are the same for all d as g goes to infinity.
Since lim g→∞ E(C)/g = 2 1/m + 1/n 1 1/m + 1/n = 2 lim g→∞ E(C i )/g = 2 for any d, the limiting value is: In our simulation, m = n = 100, thus lim g→∞ (PDC) ≈ 23.48, which is very close to the far right end of each (dashed/dotted) curve in Figure 4. This indicates the high quality of this estimate of the limiting PDC.

C.1 All Permutations
Under the setting of Section 2.1, let us first consider m = n. As defined in Section 2.3, R i is the number of observations in each class that switch labels in permutation i. Let {X j |j ∈ J R i } be the cases in the original class +1 that are labeled as -1 and {Y k |k ∈ K R i } be the cases in the original class -1 that are labeled as +1 in one permutation. Let √ M 0 be the difference of the class means of the non-permuted data (let R 0 = 0) and let √ M i be that of permutation i. Since In order to calculate E(M 0 M i ), let and W j , U j be entries of W, U . We have  = 8d σ 4 n 4 (2R i − n) 2

C.3 Additive Property
In this section, we only consider all permutations since the similar calculations also apply to balanced permutations. In Section 3.1, we have Cor( thus the marginal distribution is: Then