Question: Spillover matrix in FlowCore doesn't match Compensation Matrix from FlowJo
0
gravatar for Samuel Ahuno
18 months ago by
Ghana/KNUST
Samuel Ahuno0 wrote:

Dear all,

I used the spillover() function in flowCore to generate a spillover matrix with a bunch of single-stained .fcs and an unstained sample.

Strangely, I compared this spillover matrix from R with that of FlowJo Compensation Matrix and found that they were dissimilar.

Perhaps, my approach was wrong but I have attached the codes for peer-review.

In addition, Kindly find below the Comp Matrix from FlowJo.

Any help will be highly appreciated.

FlowJo Comp Matrix

 

 

Best,

Sam

 

#My flowSet namely “compflowset3” contains 8 single-stained compensation files and 1 unstained sample

> sampleNames(compflowset3)

[1] "Compensation Controls_APC-H7 Stained Control_018.fcs"   

[2] "Compensation Controls_APC Stained Control_017.fcs"      

[3] "Compensation Controls_Aqua Amine Stained Control_020.fcs"

[4] "Compensation Controls_BV421 Stained Control_019.fcs"    

[5] "Compensation Controls_FITC Stained Control_013.fcs"     

[6] "Compensation Controls_PE-Cy7 Stained Control_016.fcs"   

[7] "Compensation Controls_PE Stained Control_014.fcs"       

[8] "Compensation Controls_PerCP-Cy55 Stained Control_015.fcs"

[9] "Sample 2_Unstained.fcs" 


#Displaying column names in order to determine the arrangement of parameters/antibodies

> colnames(compflowset3)

 [1] "FSC-A"        "FSC-H"        "FSC-W"        "SSC-A"        "SSC-H"      

 [6] "SSC-W"        "FITC-A"       "PE-A"         "PerCP-Cy55-A" "PE-Cy7-A"   

[11] "APC-A"        "APC-H7-A"     "BV421-A"      "Aqua Amine-A" "Time"       


#Deleting unnecessary/unused channels (In other words, I’m keeping channels that corresponds to single-stained comp files in my experiment such as FITC, PE etc..)

> deletedChanells= compflowset3[,c(7,8,9,10,11,12,13,14,1,4)]

> deletedChanells

A flowSet with 9 experiments.

  column names:

  FITC-A PE-A PerCP-Cy55-A PE-Cy7-A APC-A APC-H7-A BV421-A Aqua Amine-A FSC-A SSC-A

> 

#Now I re-order the fcs files in my flowSet "deletedChanells" to match the column names in deletedChanells; after which I assign it to a new FlowSet variable “compflowSetSpill”
 > compflowSetSpill = deletedChanells[c(5,7,8,6,2,1,4,3,9)]


# Just to keep you in the loop
> summary(compflowSetSpill)

$`Compensation Controls_FITC Stained Control_013.fcs`

          FITC-A    PE-A PerCP-Cy55-A PE-Cy7-A   APC-A APC-H7-A BV421-A

Min.      -133.9  -165.1       -143.0  -118.30  -66.70 -152.900  -42.84

1st Qu.     14.3    13.0         10.4   -18.20   24.15  -29.900   80.92

Median     114.4   141.0         91.0    14.30   47.15    3.450  111.90

Mean      4861.0  1036.0        120.4    23.85   51.48    6.226  122.30

3rd Qu.   8592.0  1827.0        208.0    55.90   73.60   40.250  145.20

Max.    128600.0 27420.0       3128.0  1158.00 2109.00  853.300 6480.00

        Aqua Amine-A  FSC-A  SSC-A

Min.          -90.44   4410   2063

1st Qu.        36.89 113300 126900

Median         78.54 120800 134300

Mean           90.72 126100 140100

3rd Qu.       127.30 125300 140000

Max.         3901.00 262100 262100


$`Compensation Controls_PE Stained Control_014.fcs`

         FITC-A     PE-A PerCP-Cy55-A PE-Cy7-A   APC-A APC-H7-A BV421-A

Min.    -114.40   -148.2       -128.7   -110.5  -66.70 -150.600  -42.84

1st Qu.   13.00     10.4         11.7      1.3   25.30  -29.900   79.73

Median    54.60    157.9        159.9     71.5   49.45    3.450  108.30

Mean      60.88   7049.0        923.8    109.6   51.01    6.745  115.50

3rd Qu.  101.40  12950.0       1688.0    188.8   73.60   41.400  140.40

Max.    3310.00 262100.0      72850.0   9265.0 1240.00  317.400 3506.00

        Aqua Amine-A  FSC-A    SSC-A

Min.          -60.69   5005     58.5

1st Qu.        21.42 112800 126500.0

Median         41.65 120400 133800.0

Mean           42.49 122700 136700.0

3rd Qu.        60.69 125000 139300.0

Max.         1391.00 262100 262100.0


$`Compensation Controls_PerCP-Cy55 Stained Control_015.fcs`

        FITC-A    PE-A PerCP-Cy55-A PE-Cy7-A  APC-A APC-H7-A BV421-A

Min.    -109.2 -167.70       -172.9   -113.1  -64.4   -152.9  -78.54

1st Qu.  -11.7  -22.10         14.3      1.3   46.0      4.6   80.92

Median    16.9   13.00      11410.0   2265.0  173.7    519.2  109.50

Mean      17.7   14.12       7988.0   1815.0  190.5    454.6  114.70

3rd Qu.   45.5   48.10      14880.0   3403.0  316.2    851.0  140.40

Max.     963.3  952.90     237300.0  56010.0 5553.0  13930.0 2833.00

        Aqua Amine-A  FSC-A    SSC-A

Min.          -64.26   4635     63.7

1st Qu.        20.23 113200 126200.0

Median         40.46 120700 133700.0

Mean           41.99 122400 136200.0

3rd Qu.        60.69 124900 139500.0

Max.         1082.00 262100 262100.0


$`Compensation Controls_PE-Cy7 Stained Control_016.fcs`

         FITC-A     PE-A PerCP-Cy55-A PE-Cy7-A    APC-A  APC-H7-A BV421-A

Min.    -133.90  -135.20       -163.8   -117.0   -73.60  -143.800  -67.83

1st Qu.  -10.40    -2.60          7.8      1.3    24.15     2.012   79.73

Median    18.20    36.40         78.0    116.3    47.15   110.400  108.30

Mean      20.27    44.43        101.4   2190.0    53.89   207.000  116.30

3rd Qu.   46.80    81.90        174.2   4166.0    72.45   368.000  140.40

Max.    5578.00 12640.00      16920.0  96750.0 17830.00 51320.000 5480.00

        Aqua Amine-A  FSC-A  SSC-A

Min.          -53.55   4622   1156

1st Qu.        21.42 113500 127300

Median         40.46 121300 135000

Mean           43.36 124400 138700

3rd Qu.        60.69 125300 140100

Max.         2585.00 262100 262100


$`Compensation Controls_APC Stained Control_017.fcs`

         FITC-A    PE-A PerCP-Cy55-A PE-Cy7-A     APC-A APC-H7-A BV421-A

Min.    -124.80 -189.80      -137.80  -118.30    -74.75   -158.7  -72.59

1st Qu.  -13.00  -20.80        10.07   -11.70     47.15      6.9   83.30

Median    15.60   14.30       136.50    26.00    215.60    217.9  111.90

Mean      15.97   15.23       198.70    39.43  12520.00   1502.0  119.00

3rd Qu.   44.20   50.70       354.90    78.00  22310.00   2703.0  144.00

Max.     211.90  269.10      3462.00   767.00 193700.00  25440.0 1128.00

        Aqua Amine-A  FSC-A    SSC-A

Min.          -65.45   4614    894.4

1st Qu.        21.42 114500 128000.0

Median         41.65 121200 134900.0

Mean           43.47 125700 139800.0

3rd Qu.        63.07 125400 140000.0

Max.          347.50 262100 262100.0


$`Compensation Controls_APC-H7 Stained Control_018.fcs`

         FITC-A    PE-A PerCP-Cy55-A PE-Cy7-A    APC-A APC-H7-A BV421-A

Min.    -136.50 -146.90       -144.3  -110.50   -59.80   -158.7  -99.96

1st Qu.  -11.70  -19.50        -19.5    -1.30    44.85      6.9   79.73

Median    16.90   15.60         15.6    59.80   115.00   5259.0  108.30

Mean      18.34   17.12         18.5    90.07   150.90   4061.0  121.60

3rd Qu.   45.50   50.70         50.7   152.10   216.20   7169.0  142.80

Max.    2547.00 2597.00       2558.0 18320.00 51650.00 262100.0 8343.00

        Aqua Amine-A  FSC-A  SSC-A

Min.          -63.07   4693   1878

1st Qu.        20.23 112600 127100

Median         40.46 120200 134900

Mean           43.54 124400 139200

3rd Qu.        61.88 124900 140200

Max.         1633.00 262100 262100


$`Compensation Controls_BV421 Stained Control_019.fcs`

         FITC-A    PE-A PerCP-Cy55-A PE-Cy7-A  APC-A APC-H7-A   BV421-A

Min.    -126.10 -143.00      -148.20  -117.00 -74.75 -148.300    -82.11

1st Qu.    1.30  -18.20       -23.40   -24.70  24.15  -32.200    177.30

Median    35.10   16.90        11.70     3.90  47.15    2.300    496.20

Mean      35.79   17.97        12.86    10.44  49.70    4.994  21880.00

3rd Qu.   66.30   53.30        45.50    39.00  73.60   40.250  38590.00

Max.     435.50  334.10       399.10   266.50 678.50  227.700 193200.00

        Aqua Amine-A  FSC-A  SSC-A

Min.          -53.55   3808   2844

1st Qu.        40.46 113100 127300

Median        127.30 120400 134600

Mean         1080.00 126400 141000

3rd Qu.      1878.00 124900 140100

Max.         9729.00 262100 262100


$`Compensation Controls_Aqua Amine Stained Control_020.fcs`

          FITC-A      PE-A PerCP-Cy55-A PE-Cy7-A    APC-A APC-H7-A  BV421-A

Min.      -128.7   -148.20      -149.50  -130.00   -71.30 -162.100   -107.1

1st Qu.     14.3     -6.50       -20.80   -26.00    10.35  -31.050    146.4

Median      58.5     31.20        13.00     2.60    33.35    3.450    227.3

Mean       110.6     77.54        48.81    18.77    41.26    9.051    678.9

3rd Qu.    117.0     72.80        49.40    36.40    56.35   39.100   1245.0

Max.    175000.0 167000.00    113200.00 30470.00 14230.00 9322.000 193100.0

        Aqua Amine-A  FSC-A    SSC-A

Min.          -67.83   3743    -72.8

1st Qu.       334.40  67570  96860.0

Median        508.10  86400 108600.0

Mean         1982.00  86800 105500.0

3rd Qu.      4051.00 104200 117900.0

Max.       112300.00 262100 262100.0


$`Sample 2_Unstained.fcs`

          FITC-A     PE-A PerCP-Cy55-A  PE-Cy7-A    APC-A APC-H7-A   BV421-A

Min.       -40.3    -65.0        -65.0    -92.30   -74.75  -139.10    -16.66

1st Qu.    170.3    154.7        105.3      5.20    10.35   -16.10    105.90

Median     210.6    200.2        154.7     45.50    31.05    17.25    135.70

Mean       325.0    316.7        250.6     82.34    53.98    31.78    293.30

3rd Qu.    262.6    257.4        214.5     93.60    56.35    54.05    170.20

Max.    262100.0 262100.0     262100.0 126200.00 56990.00 57510.00 262100.00

        Aqua Amine-A  FSC-A  SSC-A

Min.          -19.04  36470   8219

1st Qu.        83.30 107500  37000

Median        105.90 126100  45950

Mean          186.80 125700  56170

3rd Qu.       133.30 143100  56430

Max.       228600.00 262100 262100



#Generating the spillover. Note I’m using this type of stain_match = "ordered"

>spilloverComp=spillover(compflowSetSpill, unstained = "Sample 2_Unstained.fcs", patt = NULL, fsc = "FSC-A",  ssc = "SSC-A", method = "median", stain_match = "ordered", useNormFilt=FALSE, pregate = FALSE, plot = FALSE)
> spilloverComp

             FITC-A PE-A PerCP-Cy55-A    PE-Cy7-A       APC-A   APC-H7-A

FITC-A            0    0    0.0000000 0.000000000 1.000000000 0.00000000

PE-A              0    0    0.1999999 1.000000000 0.707692366 0.00000000

PerCP-Cy55-A      0    0    1.0000000 0.197227831 0.012670206 0.04460117

PE-Cy7-A          0    0    0.0000000 0.760601173 0.172839501 1.00000000

APC-A             0    0    0.0000000 0.000000000 0.919770760 1.00000000

APC-H7-A          0    0    0.0000000 0.002728122 0.016015797 1.00000000

BV421-A           0    0    0.0000000 0.000000000 0.044651519 0.00000000

Aqua Amine-A      0    0    0.0000000 0.000000000 0.005718261 0.00000000

               BV421-A Aqua Amine-A

FITC-A       0.0000000   0.00000000

PE-A         0.0000000   0.00000000

PerCP-Cy55-A 0.0000000   0.00000000

PE-Cy7-A     0.0000000   0.00000000

APC-A        0.0000000   0.00000000

APC-H7-A     0.0000000   0.00000000

BV421-A      1.0000000   0.05940594

Aqua Amine-A 0.2278106   1.00000000

> 
ADD COMMENTlink modified 18 months ago • written 18 months ago by Samuel Ahuno0

Hi Samuel.

I don't have an answer. I already did some test using OMIP018 and this function was OK with the parameters you used. Look at my tests at http://rpubs.com/SamGG/spillover-omip-018 and issue IMHO concerning the row normalization https://github.com/RGLab/flowCore/issues/94

I encouraged you to read the test code provided by Mike at Error in dimnames(x) <- dn : length of 'dimnames' [1] not equal to array extent and I would like to thanks Miha for interesting discussion also.

In case you want to go into the code, I extracted the useful part of the code from the spillover method. You will find original comments, plus mine, plus some points to check (comment identified by #-#). You can run again your code and specifying the unstained with its numeric index instead of its long name.

I hope this will help you.

x = spilloverComp
unstained = "Sample 2_Unstained.fcs"
fsc = "FSC-A",
ssc = "SSC-A"
method = "median"
stain_match = "ordered"

allcols <- colnames(x)
cols <- allcols
## Ignore these guys if they somehow got into cols.
cols <- cols[!(cols %in% c(fsc, ssc))]

## There has got to be a better way of doing this...
if (!is.numeric(unstained)) {
    unstained <- match(unstained, sampleNames(x))
    if is.na(unstained)) {
        stop("Baseline(unstained sample) not found in this set.", call. = FALSE)
    }
}
#=# Check this is the true index of the unstained sample
#=# Alternatively, you could put the true index, ie length(x) in your case

# Here, we match the stain channels with the compensation controls
# if the user has specified it. Otherwise, we must "guess" below
# based on the largest statistic for the compensation control
# (i.e., the row).
# If "ordered," we assume the ordering of the channels in the
# flowSet object is the same as the ordering of the
# compensation-control samples.
channel_order <- seq_along(sampleNames(x))[-unstained]
#-# This is useless in ordered case

# Real computation starts here
# Firstly compute the median per column for each FCS
inten <- fsApply(x, each_col, method)[, cols]
#-# Print the inten matrix, and check the name of the columns
#-# cbind(sampleNames(x), c(colnames(inten), "-"))

# background correction
# Secondly remove the unstained medians from the single stained FCS
# per column, avoiding negative values
inten <- pmax(sweep(inten[-unstained, ], 2, inten[unstained, ]), 0)
#-# Print the inten matrix

# normalize by max of each row
# Thirdly divide by maximum of each row, which might lead to
# a diagonal different from 1
inten <- sweep(inten, 1, apply(inten, 1, max), "/")
#-# Print the inten matrix

# Updates the "rownames" of the intensity matrix. If the channel
# order was not set above, then a guess is made based on the
# largest statistic for the compensation control (i.e., the row).
rownames(inten) <- colnames(inten)
inten
#-# Check against FlowJo, but FJ channels are not in the order of the flowset
#-# round(inten*100, 2)
ADD REPLYlink written 18 months ago by SamGG190
Answer: Spillover matrix in FlowCore doesn't match Compensation Matrix from FlowJo
0
gravatar for Samuel Ahuno
18 months ago by
Ghana/KNUST
Samuel Ahuno0 wrote:

Kindly find below the Comp Matrix from FlowJo.

Any help will be highly appreciated.

Comp Matrix from FlowJo

https://drive.google.com/open?id=1MIq65H71aXhx_hAr0G_i6YXlNY_-mZis

ADD COMMENTlink written 18 months ago by Samuel Ahuno0
Answer: Spillover matrix in FlowCore doesn't match Compensation Matrix from FlowJo
0
gravatar for Samuel Ahuno
18 months ago by
Ghana/KNUST
Samuel Ahuno0 wrote:

Many Thanks, Sam!

I will look into the codes and get back to the community on that.

 

Best

Samuel

ADD COMMENTlink written 18 months ago by Samuel Ahuno0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 242 users visited in the last hour