Sunday, May 31, 2015

Lazy Sunday- Tidbit of GLMM


If you're getting an error message about "failure to converge" or anything to do with "eigenvalues"- scaling usually makes the model work.

Don't go to excel file to create new z.scores.

Take the variables you want to look at (If I'm using Poisson, I leave the dependent variable alone) and put it in a data.frame

Then data.frame<-scale(data.frame)

I wish I figured this out sooner.


Monday, May 18, 2015

One of the Mantis Shrimp Died.


The male mantis shrimp died.
The female started to eat the body.
Who run the world?
Girls.

Friday, May 15, 2015

Image Friday!


While I'm in that weird limbo where I just finished undergrad and now heading off to grad school.
I got a new job as a research assistant! Well, not really new as it's the same lab I've been working in. Different project and different boss!

But it is probably one of the coolest thing ever- my new boss (Theresa! She wrote Coupling unstable agents in biological control in Nature Communications (Jan 2015)) is doing a modern update on the
Huffaker's Mite Experiment (WIKI). Specifically, looking at how dispersal can allow for co-existence between prey and predators (specifically aphids and lady beetles).

Coolest thing I have ever seen. And hey I get to see what comes out of it at the end!



Aphids are a lot cuter than wasps!
And hey I'm actually working with live specimens!


Well, another cool thing is that the lab got mantis shrimps and some star-fishes.


Since everybody is leaving to do field work, I was drafted into taking care of them!

The shrimps were already named (Anne and Noam). I had a chance to name one of the starfish.
His name is Patrick.

The resemblance is striking. No?



Sunday, May 10, 2015

A non-biology data set for people to use! The Hot 100 Billboard- Number one songs!


The #1 Song 2010- 2015 on the Hot 100 Billboard

Disclaimer: Still working on this, the actual duration (week at the number #1 spot) may be a bit off.
Also, god forbid, don't do any analysis that has to do with genre- again still working on it. Is it pop, hip-hop, rap? Is there a difference between electropop and regular pop? Is Adele considered pop (I put her in this category)- feel free to download and change.

Go nuts!

Note:
Single/Group: Single artist versus groups. Doesn't matter if it's a feat. song
Collaborative means feat songs

Here are some questions I want to know the answer to:
(Good R practice)
Is a collaborative song more likely to stay at the #1 spot longer?
Are the #1 songs by female artists more likely to stay at the #1 spot longer?
Who are the biggest rivals when it comes for battling the #1 spot?

Here are some graphs I have made:

Figure 1: The total duration (weeks) that the artist's songs have been at the number 1 spot.


Figure 2: How many songs by the artists nabbed the #1 spot

Figure 3: The number one songs and their total time (weeks) on the #1 spot

Friday, May 8, 2015

Not Biology Friday- Star Wars Rant


Things that bother me/don't get about Star Wars:

1) People telling me that Star Wars: The Old Republic is the sequel to Knights of the Republic. No, it's not. It's like centuries after the second game. It is also an MMO. Come on guys. 

2) Revan being canonically male. Player's choice, come on Bioware.
3) Meetra Sulik (The Exile) being canonically female. Player's choice, come on Bioware.

4) Spoiler. Meetra Sulik being unceremoniously killed off. Come on Bioware. 

5) People underrating Knights of the Old Republic 2. It literally had the best plot in the Star Wars Universe. The greatest antagonist ever in Darth Traya.

6) Bendak Starkiller being Darth Vader's apprentice.

7) The Force Unleashed series in general. The whole game literally makes the ability to use the force almost petty.

8) Midichlorians.

9) Vibroswords. Just use a blaster. I mean I can forgive it for being the Old Republic era, but...

10) Sith not only being an ideology, but a race.
11) The Expanded Universe after the original trilogy. Only thing good is Mara Jade.

12) Whatever happened to the Star Forge? 

13) Starwars 1313 cancellation.

14) People forgetting that Princess Leia is force-sensitive.

15) Carth Onasi. 

16) The whole Jedi Council in the Old Republic and the Republic in the movies.

17) Not having a KOTOR 3.

18) The Jedi bastardizing the original Jedi Code.

19) Extra Star Trek: Why does Captain Janeway break the Prime Directive?

How to: Plotting multiple smooth regression lines in a single graph with R (ggplot2) (Star Wars)

Hopefully you're going to be a Star Wars fan, because that's the example we're going to use.
So in the second and third episode of the prequel trilogy, there's war going on between the Republic  (The Goodies) and the Separatists (The Baddies)

All you really have to know is that:

On one side (The "Good" side)  there are the Jedi Masters (the ones with the lightsabres) and there are Clone Troopers
(Skip to Scenario if you want to see the R codes)

Yes, I am aware that Satele Shan was not in the Clone Wars.
On the "evil" side:

We have Sith Lords and then we have the droids:
Yeah, yeah- breaking the Rule of Two. Shush

SCENARIO:

Even with a war going on there are still people who use R!
They want to see if the number of fatalities for the droids, Sith Lords, and Clone troopers are affected by the number of Jedi Masters on the battlefield. Do these arrogant, know-it-all hippies actually contribute?  To keep this simple, the data analysts decide to use smooth regressions!  And they want to show on one graph, the:

Droids Destroyed versus Number of Jedi Masters
Clone Troopers killed versus Number of Jedi Masters
Sith Lords killed versus Number of Jedi Masters.

For the Jedi supporters, they probably want the number of droids and Sith Lord fatalities to increase with more Jedi Masters on the field and less clone trooper deaths with more Jedi Masters.

Because I'm lazy, I decided to randomly generate numbers in an Excel file!

Now I kinda set it up in this format:
Download from Google Sheet (StarWars
Note that is an Excel file and I'm working with CSV



Well, let's do it!

(Disclaimer: There are multiple and better way of getting the same-end product! Seriously, please free to point out "Hey, why did you write 15 lines of code when it's easy with just 2 lines?". That's how I learn! Also this example is for ggplot2 not for stats) 

So let's say you downloaded the file!
Set your work station where you put the file!
And then let's write some code!

One thing we're going to need is the reshape2 package and the ggplot2 package.

So one problem that I found when I was using a data file that was in the format above is that I couldn't figure out a way to say to R (specifically ggplot2), "Hey, the y value is going to be the droids, Jedis, and Sith Lords. The x value is just the number of  Jedi Masters"

So after some minutes of fooling around, I decided to use the reshape package

After, I melted the data it came to look like this:




So let's plot the points!

Graph 1: Just the points of Fatalities versus Jedi Masters 


Hm... Not seeing much a pattern. Maybe Order 66 was the right thing to do.

Now lets fit some lines.



The Chancellor demands that we take out the distracting points.


Miscellaneous: Change the Legend!

While we need to actually run some statistical tests to verify, from the graph, the presence of Jedi Masters seem to have little effect on the number of fatalities. 





Wednesday, May 6, 2015

The codes where are they?



Took down the previous codes.
Making new examples and new graphs.
Making it more readable for one thing.

Pretend you're Leslie Knope and I'm feeding you a waffle of R-code.


Monday, May 4, 2015

Tea-Tortrix and Baculovirus.


The Tea Tortrix, an important agricultural pest for tea plantations, has some pretty metal natural enemies. Beside the parasitoid wasps which lay their eggs in the moth larvae, there is the baculovirus that is the scourge of the Lepidopteran world. This double stranded DNA virus has been an important specimen (perhaps favorite) for many molecular biologists particularly because how brutal and effective these viruses are when it comes to utilizing their hosts.

NPR did a report on the baculovirus and gypsy moth where they found that the gene "egt" is responsible for altering the physiology and behavior of the gypsy moth. Gypsy moths usually eat at night, climbing to the top part of the tree to eat the leaves. However, the baculovirus alters the larvae's behaviors forcing the infected larvae to stay in the top part of the trees. The virus multiplies in its host and with the help of some enzymes that eats away at the exoskeleton, the larvae literally become liquefied. The high vantage point is crucial in allowing the millions of the viral particles to fall on the leaves below where other unlucky larvae could get infected by eating these tainted leaves.

Now my rambling aside, why is my blog titled  baculovirus and Tea Tortrix?


Interestingly, the baculovirus has been known as "the Wilt" and surprisingly it "may be responsible ofr kiling considerably more than half the population".

(Source: C.B Redman King, 1937)

Now the question I'm seeking to answer is:
How will increasing global temperature affect the baculovirus? In turn how will it affect the Tea Tortirx population? 

I need more coffee.

Saturday, May 2, 2015

[Low Effort Saturday] Baculovirus

Baculoviruses are awesome.

They liquefy an unfortunate larvae inside out. How metal is that?

(Michael Grove/Science/AAAS)