RGLab / openCyto

A package that provides data analysis pipeline for flow cytometry.
GNU Affero General Public License v3.0
75 stars 29 forks source link

How to merge two groups which have slightly different order of marker names #147

Closed kdh4win4 closed 6 years ago

kdh4win4 commented 7 years ago

Dear Mike and Finak, I have two fcs groups. They have same 13 markers with slightly different name order. "CD16" is 6th marker in first group but 13th marker in second group. Can I know how to solve this issue ?

> chnl_n <- markernames(gs_n);chnl_n 
 [1] "KIR3DL1"       "CD57"          "CD8"           "AQUA"          "HLADR"        
 [6] **"CD16"**          "KIR2DL2DL3DS2" "CD14CD19"      "CD56"          "CD3CD4"       
[11] "KIR2DL1DS1"    "CD62L"         "A4B7"         

> chnl_p <- markernames(gs_p);chnl_p 
 [1] "KIR3DL1"       "CD57"          "CD8"           "LIVE/DEAD"     "HLA-DR"       
 [6] "KIR2DL2/3/DS2" "CD14/19"       "CD56"          "CD3/4"         "KIR2DL1/DS1"  
[11] "CD62L"         "A4B7"          **"CD16"**    

Other marker names are easily changed. There is no issue but CD16. Thank you for your time.

mikejiang commented 7 years ago

markernames are not the problem, you want to make sure their channel names (i.e colnames) are in the consistent order. Because openCyto uses channel name as the index to read the flow data and define the gates. If the channels are equivalent and just in the different order, you can simply put these two GatingSets into GatingSetList container and you can pretty much use it as a merged GatingSet

gslist <- GatingSetList(list(gs_n, gs_p)) 
kdh4win4 commented 7 years ago

Thank you, Mike. There is one more issue. CD16 is fine. However, AQUA vs LIVE/DEAD, HLADR vs HLA-DR has different name.


> gslist <- GatingSetList(list(gs_n, gs_p))
Error in validObject(x) : 
  invalid class “GatingSetList” object: GatingSet 1 and 2 : colnames of flowSets don't match!

Can I know how to match these ? Thank you so much for your time.

mikejiang commented 7 years ago

You can use partial match (i.e. HLA) in your gating template to handle second case. For AQUA, you either rename it to LIVE/DEAD through markernames<- replacement method (make sure you refer to the doc to understand how to use it) or use the channel name instead (assuming channels are consistent between these two GatingSets)

kdh4win4 commented 7 years ago

There are two groups; gs_n and gs_p

markernames <- has error a message;

>markernames(gs_p) <- chnl_p
Error in `markernames<-`(`*tmp*`, value = c("KIR3DL1", "CD57", "CD8",  : 
  value must be a named character vector!

channel names are consistent except CD16 case(pacific, V450).

> pData(parameters(getData(gs_n[[1]])))[,1:2]
                    name          desc
$P1                FSC-A          <NA>
$P2                FSC-H          <NA>
$P3                SSC-A          <NA>
$P4                SSC-H          <NA>
$P6                 Time          <NA>
$P7  <Alexa Fluor 700-A>       KIR3DL1
$P8              <APC-A>          CD57
$P9           <APC-H7-A>           CD8
$P10  <AQUA LIVE/DEAD-A>          AQUA
$P11            <FITC-A>         HLADR
$P12    <Pacific Blue-A>          CD16
$P13              <PE-A> KIR2DL2DL3DS2
$P14          <PE-Cy5-A>      CD14CD19
$P15          <PE-Cy7-A>          CD56
$P16    <PE-Texas Red-A>        CD3CD4
$P17     <PerCP-Cy5-5-A>    KIR2DL1DS1
$P18        <Qdot 605-A>         CD62L
$P19        <Qdot 655-A>          A4B7
> pData(parameters(getData(gs_p[[1]])))[,1:2]
                    name          desc
$P1                FSC-A          <NA>
$P2                FSC-H          <NA>
$P3                SSC-A          <NA>
$P4                SSC-H          <NA>
$P5                 Time          <NA>
$P6  <Alexa Fluor 700-A>       KIR3DL1
$P7              <APC-A>          CD57
$P8           <APC-H7-A>           CD8
$P9   <AQUA LIVE/DEAD-A>     LIVE/DEAD
$P10            <FITC-A>        HLA-DR
$P11              <PE-A> KIR2DL2/3/DS2
$P12          <PE-Cy5-A>       CD14/19
$P13          <PE-Cy7-A>          CD56
$P14    <PE-Texas Red-A>         CD3/4
$P15     <PerCP-Cy5-5-A>   KIR2DL1/DS1
$P16        <Qdot 605-A>         CD62L
$P17        <Qdot 655-A>          A4B7
$P18        <Qdot 800-A>          <NA>
$P19            <V450-A>          CD16

Thank you very much for your time, Mike.

mikejiang commented 7 years ago

Once again, as I said, you should read the doc to understand the API before using it, Note that both the doc and your error message clearly tells you where the problem is: value must be a named character vector!

anyway, here is the quotes from ?`markernames,GatingSet-method`

Arguments: value: named character vector for markernames<-, regular character vector for colnames<-.

Examples: markers.new <- c("CD4", "CD8") chnls <- c("\<B710-A>", "\<R780-A>") names(markers.new) <- chnls markernames(gs) <- markers.new

kdh4win4 commented 7 years ago

Well, I read the markernames() information in flowCore and Opencyto vignette, however, it is not easy to understand fully. Thank you for your code example, however, it did not work in my case. I just detour this issue and almost escape this issue by gating two group separately and get together at the plotgate process. Well, this is just my humble guess. Is there any way to change the marker names at early "read.fcs" stage? Thank you so much for your help.

kdh4win4 commented 7 years ago

I solve this issue by using a minimum keyword. Thank you.

kdh4win4 commented 7 years ago

I reopened this issue since the different marker order couldn't be solved just a few keywords. The first group has CD16 at 6th position. The second group has CD16 at 13th position. Can I know how to solve this issue ?

> chnl_n <- markernames(gs_n);chnl_n #
 [1] "KIR3DL1"       "CD57"          "CD8"           "AQUA"          "HLADR"        
 [6] "CD16"          "KIR2DL2DL3DS2" "CD14CD19"      "CD56"          "CD3CD4"       
[11] "KIR2DL1DS1"    "CD62L"         "A4B7"         
> chnl_p <- markernames(gs_p);chnl_p #
 [1] "KIR3DL1"       "CD57"          "CD8"           "LIVE/DEAD"     "HLA-DR"       
 [6] "KIR2DL2/3/DS2" "CD14/19"       "CD56"          "CD3/4"         "KIR2DL1/DS1"  
[11] "CD62L"         "A4B7"          "CD16"         
mikejiang commented 7 years ago

Thank you for your code example, however, it did not work in my case.

Can you post your full transcript and message? The simple sentence like this doesn't really help anyone to understand where your problem was