Wednesday, 24 September 2014

Playing with flow cytometry data in R....

So, I have been using Amy's flow data to try and grapple with data into R.

Making some progress!

I have managed to get some FCS data into R:

ntl<-read.FCS("A01 NTL.fcs")

plot(ntl, c("FSC-A", "SSC-A"), xlim=c(0, 5000000), ylim=c(0, 500000))

draws a nice dot plot:



So there is a data format issue. We have:
  • Formal class flowSet
  • Large flowFrame
  • Formal class workFlow
According to this: http://master.bioconductor.org/help/course-materials/2010/BioC2010/intro.pdf


flowFrame - a class representing the data contained in a FCS file.
1. raw measurement
2. keywords in the FCS files
3. annotation for parameters (stains, sample names, range)

flowSet - a collection of flowFrame.

So it is possible to do gating but I am finding it difficult to understand and make work. 
Some info here but it's a bit challenging:
http://master.bioconductor.org/help/course-materials/2010/BioC2010/AnalyzingFlowData.pdf


Thursday, 11 September 2014

passing variables...



Passing them within functions.

https://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/298104/passing-variables-from-one-function-to-another

http://stackoverflow.com/questions/10579713/passing-a-local-variable-from-one-function-to-another

http://javascript.about.com/od/3functions/a/fun06.htm

Learning how to make JSON....

So the key piece of code is JSON.stringify

This example shows it very simply:

var a = [];
a.push({ name: 'x1' });
a.push({ name: 'x2' });
console.log(JSON.stringify(a));

In the console log you get:

[{"name":"x1"},{"name":"x2"}] 


So testing this:
      var start = 21;
      var a = [];
      a.push({ name: start });
      a.push({ name: 'x2' });
      console.log(JSON.stringify(a));   

In the console log you get:
     [{"name":21},{"name":"x2"}] 

GOOD!!!!

VERY STRANGELY, EVEN WHEN I SEND IT AS JSON, THE SCRIPT I HAVE WRITTEN DOESN'T SEEM TO LIKE IT. 
I DON'T KNOW QUITE WHY!


Surprisingly, a variation on push seems to work:

           var start = 21;
           var end = 193;
           var color = "blue";
           
           var a =[];
           a.push({ 'start': start, 'end': end, 'color': color });

This gives data that the molecule renderer seems to like. 


Internet Explorer 8

So it seems that IE8 does not support SVG or responsive websites very well.
This is a bit disappointing as IE8 is on lots of Uni machines and lots of staff have IE8 on their browser.

It seems very likely that this was Michael Stechman's problem too!

However, with a bit of work this morning, I think I have found a way around this - IE8 specific code!

Some helpful links:
    http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

from which I copied the code:
<!--[if lte IE 8]> <link rel="stylesheet" type="text/css" href="ie8-and-down.css" /> <![endif]-->

A general terms for these are Conditional Comments - they seem to be an Internet Explorer specific thing.
    http://www.quirksmode.org/css/condcom.html


It's not just limited to styles sheets, you can also use this code in the html to include pictures and other content.


There is also some additional code required because of bootstrap as well.
I copied these from the bootstrap website:

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->


This is all required because some of the Cardiff Uni computers still use IE8!!! 

Let's hope my pages work on these now. 






Wednesday, 10 September 2014

Extracting protein sequence

So I want to write a javascript that will extract a protein sequence.

Extracting from the straight XML webpage has some challenges because the source has multiple XML tags.

So I tried the DAS server which has been used before.

Link to the DAS server: http://www.ebi.ac.uk/uniprot-das
The DAS server has XML files for sequence and for features.
It will prove easier to extract data from I think.



Yes, this works better and I have written a script that will extract the sequence.
Success!!!


Finding out more about BioJS workflows...

Key aspects of the work flow include:

testing - mocha

http://visionmedia.github.io/mocha/

Some interesting stuff here:
http://blog.codeship.io/2014/01/22/testing-frontend-javascript-code-using-mocha-chai-and-sinon.html



GULP (what is this?)

Tuesday, 9 September 2014

BioJS Edu....

So I made my first pull request on BioJS edu and it has been accepted.
I have been invited as part of the BioJS team so that's nice too.

I have spent most of the day trying to work out how to use the new BioJS 2.0 files in html pages.

Unfortunately, not with much success.

However, I have managed to get one to work at last!!

The file:

file:///Users/paulbrennan/Documents/Aptana%20Studio%203%20Workspace/biojs/index20140909.html

doesn't write any text to the screen but does write something to the console.

It loads up the script from

<script src="https://drone.io/github.com/greenify/biojs-io-fasta/files/build/biojs_io_fasta.min.js"></script>

and runs it in the script tag:

It pulls some code from in this way:

 biojs.io.fasta.parse.read("http://dev.biojs-msa.org/v1/dummy/PF00072.fasta", function(seqs){ console.log(seqs); });

This is all fine as far as it goes but it's a bit artificial.

However, it does at least show that it works and that I can make it work in some naive format.

Full set of code:

<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Paul Brennan">
    <link rel="icon" href="../../favicon.ico">

    <title>Playing with BioJS 2...</title>

    
    <!-- load up the scripts -->
    <script src="https://drone.io/github.com/greenify/biojs-io-fasta/files/build/biojs_io_fasta.min.js"></script>
    
    <script>
         biojs.io.fasta.parse.read("http://dev.biojs-msa.org/v1/dummy/PF00072.fasta", function(seqs){ console.log(seqs); });
    </script>   

 </head>

<body>
    

</body>