Wednesday 24 September 2014

1D histogram from Flow data AGAIN

plot(ntl, "FL4-A", breaks=10000, xlim=c(0,100000))

this "breaks" makes a real difference!


Links for R flow packages and info re 1D histogram

http://www.bioconductor.org/packages/release/bioc/manuals/flowViz/man/flowViz.pdf

http://www.bioconductor.org/packages/release/bioc/vignettes/flowCore/inst/doc/HowTo-flowCore.pdf


Found a little about how to plot 1D histograms:

plot(ntl, c("FL4-A"), breaks=10000, xlim=c(0, 100000))

Plot needs some kind of log transformation for sure.


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>

BioJS 101 tutorials

Headstart

So first thing is to write a very simple script with javascript.

This can then be run by node so long as you are in the correct folder.



Package basics

Important point:
For BioJS 2 components, we have following naming conventions:
biojs-[io/rest/vis/algo/…]-[name]
  • Use io for components which are responsible for parsing data into a specific format (aka parser)
  • Use vis for components which are visualizing data sets
  • Use rest for REST apis to databases
  • Use algo for server/client side algorithms processing the data (e.g. alignments, neural networks, markov models, graph algorithms)

require is a special function provided by node.js

package.json
   this seems to contain the key information about the package.

npm

npm
stands for node packaged modules.

But what does it really mean?

According to Wikipedia:
npm (Node Packaged Modules) is the official package manager for Node.js.

Brew, git and node.js AND my first pull request...

So these are three packages that are worth having on your mac to do software development.

Homebrew, git and node.js are three packages that are worth having on your Mac if you want to do software development.
Homebrew is called the 'missing package manager for OS X'. It allows you to download packages onto your Mac from your command line.
Git is a version control system that will keep track of the changes you have made in code.
Node.js is an 'asynchronous event driven framework'.

So, I have made my first pull request to a tutorial. 
I hope I have done it correctly and I am pretty happy about it so far!!

Using Git in Aptana

So, you need to choose the 'App Explorer' to find the Git settings in Aptana.
Once you do this, you find the 'Stage' and 'Commit' Buttons.



Monday 8 September 2014

BioJS again...

Getting started from

http://edu.biojs.net/series/101/20_getting_started.html#mac

installing npm

What is this again?
Let's find out...

Wikipedia: http://en.wikipedia.org/wiki/Npm_(software)
npm stands for Node Packaged Modules

It's for downloading software onto your computer


Arghh trying to update the page too and find a way to make it work.

Fork into github.
Then trying to import this into Aptana.

Import...
    Git repository as new project...
        Use URI....




Using BioJS in your own webpage

Go to github:

https://github.com/biojs/biojs

This has the library of components.

Download these by pressing the "Download ZIP" button.
Then unzip the library.

No this is NOT the right place!

To actually down load the libraries, you need to go here:
https://github.com/biojs/biojs/releases
N.B. This is a large file that contains all the dependencies for BioJS.
These in themselves are very large files!!!!

59.6 MB
so it contains a lot.


Another option:
Point to somewhere that the library is.

myFavouriteProtein

So, I am trying to link BioJS with bootstrap and write a tutorial that allows this.

I can successfully, put in the sequence module.

The ProteinPortafolio module gives structure but not the proper information.

Let's spend some time trouble shooting that.


Ok, so I tried to simplify.
Get rid of all the bootstrap stuff in case there was some kind of CSS conflicts.

Sadly, still no text.
Also, I think there is an error in the documentation which I have circumvented by including the

Biojs.Tooltip.js script. 

I am not sure why this work but without this script there is no structure. 

Let's try just the 3D structure file. 
Simplify!

Arghhh!
The only BioJS that I can really get to work is the Sequence module. 
Why is this?

Need to try again from a different direction.