FAQ  •  Register  •  Login

Keep the same viSNE plot when clustering...

Forum rules
Please be as geeky as possible. Reference, reference, reference.
Also, please note that this is a mixed bag of math-gurus and mathematically challenged, so choose your words wisely :-)
<<

Nomeansno

Participant

Posts: 5

Joined: Mon Apr 30, 2018 9:37 pm

Post Tue May 29, 2018 9:54 pm

Keep the same viSNE plot when clustering...

First post.... be nice :)

viSNE is a nice way to show your results to your boss and keep him hooked to your datas. I usually start by doing a viSNE analysis in cytobank and I cluster everything using Phenograph in Cytofkit.

The thing with viSNE is that once you get use to the look of one analysis, it's really hard to switch to a new one (same set of data, different seeds). Comparing a viSNE made in cytobank to one made in Cytofkit is really annoying. I tried to run a phenograph analysis using the same seed as in cytobank, for the viSNE output. Both viSNE are different. So, is there a way to run phenograph and visualize results on an already made viSNE?

Thanks for your time!
<<

ErinSimonds

Master

Posts: 50

Joined: Tue May 13, 2014 8:04 pm

Post Wed May 30, 2018 5:59 am

Re: Keep the same viSNE plot when clustering...

Hi Gael,

Cytofkit should have created a subfolder in the output folder called "YourProjectName_analyzedFCS"

If you ran both tSNE and PhenoGraph using cytofkit_GUI() then the FCS files in the "analyzedFCS" subfolder should have the tSNE coordinates and cluster IDs appended to the FCS file as additional columns. The parameters tsne_1_linear and tsne_2_linear are the X and Y coordinates of the tSNE plot generated by cytofkit, while Rphenograph_clusterIDs is the cluster IDs as integers. You can upload these files to Cytobank, view the data in tSNE space, and gate on it (tip: adjust the scales to make gating easier).

For example, here is a file (blahblahblah_ViableSinglets.fcs) from a recent analyzedFCS subfolder of mine. I loaded it into R using flowCore's read.FCS() function, and then checked which parameters are present:

  Code:
> myfcs <- read.FCS("blahblahblah_ViableSinglets.fcs", transformation = FALSE)
> myfcs
flowFrame object 'blahblahblah_ViableSinglets.fcs'
with 2321 cells and 70 observables:
                       name                   desc   range    minRange maxRange
$P1                    Time                   Time 3087428  0.00000000  3087428
$P2            Event_length           Event_length      75  0.00000000       75
$P3                   Y89Di              089Y_CD45     503  0.00000000      503
.... a bunch of markers ...
$P64                 tsne_1                   <NA>    3178 -0.08243132     3177
$P65                 tsne_2                   <NA>    3177  0.00000000     3176
$P66          tsne_1_linear                   <NA>      66  0.00000000       65
$P67          tsne_2_linear                   <NA>      73  0.00000000       72
$P68      Rphenograph_cor_1                   <NA>    3175 -0.08145589     3174
$P69      Rphenograph_cor_2                   <NA>    3178 -0.08237541     3177
$P70 Rphenograph_clusterIDs                   <NA>      14  0.00000000       13
654 keywords are stored in the 'description' slot


If you want to work in R, you can then plot the data in tSNE space with a color overlay. For example, here are some quick one-liners (not the prettiest plots):

  Code:
palette(rainbow(max(exprs(myfcs)[, "Rphenograph_clusterIDs"])))
plot(tsne_2_linear ~ tsne_1_linear, data=as.data.frame(exprs(myfcs)), col=Rphenograph_clusterIDs, pch=16, main=description(myfcs)$GUID)

or
  Code:
plot(tsne_2_linear ~ tsne_1_linear, data=as.data.frame(exprs(myfcs)), col=(asinh((Y89Di)/5)), pch=16, main=description(myfcs)$GUID)


You mentioned that in your workflow, you first performed viSNE in Cytobank, then used Cytofkit to run PhenoGraph. That's the reverse strategy of what I proposed above, but it's fine too. If you export the FCS files from Cytobank's viSNE experiment, I believe it will include parameters named tSNE1 and tSNE2 appended to the FCS file. In that case, just skip the tSNE step in cytofkit (i.e. only run PhenoGraph) when you use these files for PhenoGraph. Be sure to include all events for clustering (don't use ciel or max). When PhenoGraph finishes, upload the clustered FCS files from the analyzedFCS folder to Cytobank. You can then use Cytobank's original tSNE1 and tSNE2 parameters to view the data, and view the Rphenograph_clusterIDs parameter as a color in the Z parameter.

You've got options. Good luck!

ES
<<

mleipold

Guru

Posts: 5796

Joined: Fri Nov 01, 2013 5:30 pm

Location: Stanford HIMC, CA, USA

Post Wed May 30, 2018 3:36 pm

Re: Keep the same viSNE plot when clustering...

Hi Erin,

Erin: you said:
"In that case, just skip the tSNE step in cytofkit (i.e. only run PhenoGraph) when you use these files for PhenoGraph."

I've really only run cytofkit from scratch (ie, no previous tSNE), using the GUI. Therefore, I want to make sure I understand what you mean: are you're saying take your Cytobank viSNE files, bring them into cytofkit, select Merge Method = all, Visualization method = NULL, Cluster Method(s) = RPhenograph? Then take those daughter output FCS files and bring them back into Cytobank for visualization (z=Rphenograph_clusterIDs)?

Or is this something you have to do from R command line, rather than the GUI?


Mike
<<

ErinSimonds

Master

Posts: 50

Joined: Tue May 13, 2014 8:04 pm

Post Wed May 30, 2018 3:57 pm

Re: Keep the same viSNE plot when clustering...

Yes, you got it, Mike. That workflow should be possible using the GUI.

So, to summarize, you can do:

Raw FCS —> Cytobank —> export viable singlets —> cytofkit: tSNe + PhenoGraph (subsample if you wish) —> Cytobank to view clusters or gate on tSNE plots

Or

Raw FCS —> Cytobank —> Gate viable singlets —> run viSNE within Cytobank —> download FCS files from the viSNE analysis —> cytofkit: PhenoGraph (all events; do not subsample) —> Cytobank to view clusters or gate on tSNE plots

ES
<<

Nomeansno

Participant

Posts: 5

Joined: Mon Apr 30, 2018 9:37 pm

Post Wed May 30, 2018 6:40 pm

Re: Keep the same viSNE plot when clustering...

Thanks both of you for your quick and useful answers!

I will try all this in a couple of minutes. I know all this doesn't make much sense (going from cytobank to clustering algorithms and back). I'm new to all this, I'm a biologist , no help from anyone but biologists, not a coder and I'm still trying different ways of getting my data organized. We have a Cytobank subscription and I personally think cytobank does a pretty good job at making all this as simple as possible. The problem is that no one seems to use Spade anymore..... so the reason I tried Cytofkit and Phenograph. Basic R is definitively out of reach for me.

If you have time, I would ask one last thing for now: is Flowjo of any use when it comes to working with FCS files already clustered or of any use at all? Flowjo is able to work fine with viSNE files from cytobank and could be useful but when I tried with clustered files exported from cytofkit (shiny app).... no luck. There is no tsne values anywhere. Working with Flowjo could be an option for some of my clients.

.... and be sure I'll ask for help getting my data to excel or prism... no R please :)

Thank!

gael
<<

Nomeansno

Participant

Posts: 5

Joined: Mon Apr 30, 2018 9:37 pm

Post Wed May 30, 2018 6:49 pm

Re: Keep the same viSNE plot when clustering...

One last thing: results must be viewed in cytobank, can't be done in the shiny app?
<<

mleipold

Guru

Posts: 5796

Joined: Fri Nov 01, 2013 5:30 pm

Location: Stanford HIMC, CA, USA

Post Wed May 30, 2018 7:07 pm

Re: Keep the same viSNE plot when clustering...

Hi Gael,

You should be able to look at cytofkit output data FCS files in FlowJo, with the appropriate new parameters from your analysis.

I have attached a screenshot ("cytofkit-FCS parameters.png) of a file from my Multicenter paper: the tSNE, PCA, and and cor values for the different outputs can usually be found at the bottom of the parameter list (after Time).

The "cor" values are the main way you can gate a particular cluster from the given clustering algorithm. See other screenshot ("Rpheno-cor.png")

For example, Rphenograph_cor_1 = 2 (ones position), Rphenograph_cor_2 = 1 (tens position) would be cluster 12 from RPhenograph. Note that the parameters start counting 0-9, not 1-10....if you look closely, there's no cluster at the origin because there's no cluster 00.


Mike
Attachments
Rpheno-cor.png
cytofkit-FCS parameters.png
<<

mleipold

Guru

Posts: 5796

Joined: Fri Nov 01, 2013 5:30 pm

Location: Stanford HIMC, CA, USA

Post Wed May 30, 2018 7:13 pm

Re: Keep the same viSNE plot when clustering...

Hi Gael,

Yes, files can be looked at in the shiny.app.

See this link for more information: https://www.bioconductor.org/packages/r ... nyAPP.html


However, it's not as flexible as looking at the files in FlowJo or Cytobank, where it's far easier to gate, etc.


Mike
<<

Nomeansno

Participant

Posts: 5

Joined: Mon Apr 30, 2018 9:37 pm

Post Thu May 31, 2018 12:32 am

Re: Keep the same viSNE plot when clustering...

Thanks everyone :)
<<

jamesaries

Participant

Posts: 14

Joined: Thu Sep 22, 2016 2:49 pm

Post Thu May 31, 2018 4:36 pm

Re: Keep the same viSNE plot when clustering...

Hi Erin and Mike,

Thanks for this - really useful to know you can look at the Phenograph clusters using 'cor'. I will have a go at this.

Erin - would you mind summarising your rationale for the second approach. Currently I have been cleaning the data in FlowJo and then using (20) exported fcs files (live CD45+ events) in Phenograph with 10000 events for each. This takes a while and my tSNE plot looks very 'busy'.

Does the dimensionality reduction step in cytobank allow you to cluster more efficiently /' quickly in Phenograph (especially if you have more files etc)?

Thanks
James
Next

Return to CyTOF data analysis

Who is online

Users browsing this forum: Google [Bot] and 13 guests