Monthly Archive for January, 2008

Page 2 of 2

Change axis labels in ggplot

By default, ggplot uses the variable name as the axis labels. Change it to something else using scale_x_continuous or scale_y_continuous


p = ggplot(diamonds)+geom_point()+aes(x=carat,y=price)

p + scale_x_continuous('x axis label') + scale_y_continuous('y axis label')

Timezones in Python

  • I had a Python datetime object, T.
  • I knew it was in Eastern time and wanted to convert to UTC.
  • I also wanted it to keep track of daylight savings time, for when I have dates later in the year.
  • Python datetime objects have “support” for timezone info, but you have to implement it yourself. Read: more coding overhead that I’m trying to avoid.

Here’s how to do it the easy way. Continue reading ‘Timezones in Python’

Return a list of codons from a sequence

There are no built-in functions (that I know of) for returning a list of codons from a sequence, but making your own is quite simple. This function is from Solution A.5 from the Python Course in Bioinformatics


def codons(s, frame=0):
    """Return a list of codons from a string, s, giving an optional frameshift."""

    codons=[]

    end=len(s[frame:]) - (len(s[frame:]) % 3) - 1

    for i in range(frame,end,3):
        codons.append(s[i:i+3])

    return codons

Configure SSH

sudo vim /etc/ssh/sshd_config 

Restart SSH

sudo /etc/init.d/ssh restart