News from the Fraser Lab

Welcome to 2015

James Fraser
02 January 2015

##Moving on up

We finished 2014 by moving to our new lab space up on the fourth floor of Genentech Hall. The two years we spent next to the Von Zastrow, Mostov, and Bivona Labs were absolutely fantastic. I became great friends with all the PIs (and Henry Bourne, our cluster office mate) and will miss the energy of all the students, postdocs, and staff on the floor. But, it was time to move to a labspace with a bit more room to spread out. We are excited to share equipment, space, and good times with the Frost, Thomson, Cheng, and Douglas labs!


In keeping with the traditions of Genentech Hall, we removed our old lab photos on the second floor and added some new ones to the display on the fourth floor.

Fourth Floor Photos

We went with a new theme surrounding Jennifer Li’s excellent cartoon of the lab. If you can’t tell what we are going for, you should stop by for a closer look!

Creepy Photo Bombs


We are welcoming Erin Poss (CCB) and Evan Green (iPQB/Biophysics) to the lab for the winter quarter. Apparently, even after PUBS they couldn’t get enough of me and Ben, who was their TA on team DUBSTEP.


We celebrated submitting two of Andrew’s papers at the same time as our lab-warming party. The Frost lab is new to the area too, and we are located on the same wing of our neighbourhood: the FR* wing!

After submitting the articles, we decided to post them on BioRXiv, a free online archive and distribution service for unpublished preprints in the life sciences, as well. The two manuscripts can be enjoyed together and continue Andrew’s work to exploit diffuse scattering to improve macromolecular models emerging from crystallography. We had great help from collaborators on this project (and the work on the second manuscript is primarily from Sacha and Pavel). As I wrote in the cover letter:

The first manuscript, “Predicting X-ray Diffuse Scattering from Translation Libration Screw Structural Ensembles”, describes a prediction of the diffuse scattering features created by TLS refinements. When combined, the two manuscripts outline a powerful strategy for validating X-ray models that include TLS refinement. Different TLS models have equivalent agreement with Bragg data (judged by Rfree), but different agreement with diffuse data (judged by the correlation coefficients of anisotropic diffuse intensities). Our results point the way forward for using more of the recorded scattering to improve models and generate new biological insights about the role of correlated motions in protein function.

The second manuscript, “From deep TLS validation to ensembles of atomic models built from elemental motions”, describes a new tool that can convert TLS matrices to multi-model (ensemble) PDB files that in particular are required for the project described in the first manuscript. This enables easier visualization and interrogation of the correlated motions proposed by TLS refinement. This algorithm discusses that, on the top of well-known conditions that the T and L matrices must be positive definite to be interpretable by such motions, there are other conditions that are usually ignored. Ignoring these conditions creates an unusual situation: although the final ellipsoids define real atomic motions, the TLS matrices imply imaginary correlated movements of rigid bodies.

Happy New Year - and we look forward to more papers and preprints in 2015!

BBCPUBS halfway point

James Fraser
25 October 2014

James takes the Ice Bucket Challenge

James Fraser
30 August 2014

Yesterday Peter Kim presented me (and Bob Stroud and Charly Craik) with the Ice Bucket Challenge. Peter and Susan Marqusee were challenged by Terry Oas. This fundraiser holds special significance for all of us because Tom Alber, our friend and my PhD advisor, recently passed away from ALS. I think that Tom would have loved the Ice Bucket Challenge.

Tom was incredibly courageous during the final years of his life. He never stopped learning about the underlying mechanisms of ALS and thinking of potential therapies. It was very painful to see him disappointed again and again by the ineffectiveness of the available treatments. Some of this disappointment is due to general difficulties in developing treatments for neurodegenerative diseases, but some of it was due to our lack of knowledge about the basic mechanisms of this disease.

I challenged Michael Eisen, Ron Vale, and Barb Zunder. Barb will help spread the message to USF. I hope that Ron will take the challenge, donate, and work to invite a top ALS researcher to create an iBioseminar or iBiomagazine video about ALS. There is a real opportunity for iBiology to use their production platform to capture the spirit of the moment. They can produce a fantastic video that describes the challenges and recent successes in understanding basic mechanisms of neurodegenerative disease.

Mike is refusing to accept the challenge to make a larger point about the relationship between funding agencies, research, and public access to research findings. I sympathize with his point. I know that Tom was always up to date on ALS research because of the journal access afforded to him as a professor at UC Berkeley. Other patients do not have this access and that is a shame. I hope that Mike will still donate to The ALS Association or to a lecture established in Tom’s memory at UC Berkeley, or both. In the meantime, here are a few open-access papers on the subject of Amyotrophic lateral sclerosis:

I’ll add more links as people send or comment on them. Fortunately, due to the hard work of people like Mike, many classic papers are now available through Pubmed Central and most journals now deposit articles after an embargo period. In diseases like ALS where it is often only a matter of a few years between diagnosis and death, an embargo of 18 months to protect journal profits seems particular unjust.

Consider making a donation to establish an infectious disease lectureship in Tom’s name at UC Berkeley and to The ALS Association

Syntax Highlighting for Pymol Scripts

Ben Barad
26 August 2014

Screenshots of pymol script before and after syntax highlighting

We write lots of pymol scripts here in the Fraser lab, and to this end I have written a language grammar to allow highlighting of the pymol syntax in .pml files in Sublime Text (and any other editor that uses textmate style grammars). It should work with just about any basic syntax that you throw at it, though more capability (for things like for loops) will be added as time goes on.

It is publically available for installation through Package Control, which will automatically update with new releases. You can also get it from Github, which will have the most up to date changes between releases (including potential new bugs).

For the curious, I wrote a longer article discussing the details of making the language grammar, and where it currently stands, on my personal website.

Making Publication-quality Charts using Python and Matplotlib

Ben Barad
20 August 2014

I originally wrote this article for my personal website, but I think it is relevant here, so with James’s blessing I am crossposting it.

Before updating the matplotlibrc

Python is currently my programming language of choice. It is the programming language taught by my graduate program to incoming first years, and in my experience it is the most common scripting language used by the scientists around me. The Fraser lab uses python almost exclusively for programming.

Because of this, when I want to work with data my first instinct is to go to python. Python is very effective for importing data, doing all of the manipulations necessary, and performing statistical tests. Ultimately, while I am aware that there are a multitude of other tools available, I would rather stick with python.

In my experience, the most painful part of using python for data analysis is visualization. Plotting in python is primarily accomplished via Matplotlib. I find the syntax fairly straightforward, but the default output of the charts leave much to be desired. In particular, I find myself messing with the spacing between the labels and the graph, the size of the labels and title, the linewidth, the colors of the objects, and the visual appearance of the regular tickmarks all to make a single figure look appealing enough to share with my peers. Trying to do this consistently is even more maddening, as it ultimately results in even more boilerplate code.

I ultimately (mostly) solved this problem by creating a matplotlibrc file which automatically imports a number of settings for every chart I choose to work with. My matplotlibrc file lives in a github repository where you can freely grab and modify it. Just put it in your ~/.matplotlib/ folder. I also thought I would use this space to talk about the decisions I made in designing the matplotlibrc to get as close as possible to publication quality images with no special styles in the python code.

Matplotlib’s defaults are unsuitable for any professional purpose

The best way for me to show the problems with the defaults in matplotlib is to show the output of a small snippet of code:

import matplotlib
import matplotlib.pyplot as plt

data = [220,14.2,150,400,420]
error = [10, 1, 20, 60, 10]
x = [i + .5 for i in range(5)]

fig, ax = plt.subplots()
bar =, data, 0.8, align="center", yerr=error)
plot = ax.plot(x, data)
ax.set_xticklabels(('wt', 'N23PP', 'N23PP/PEKN', 'PEKN', 'N23PP/PEKN/L28F'))
ax.set_title(r"Everything in the document can use m$\alpha$th language", y=1.05)
ax.set_ylabel(r"Rate (s$^{-1}$)", labelpad=10)

In this code, I start with two lists, one of y values and one of error values, and proceed to make a named bar chart. I also throw a line graph on top for illustrative purposes and add some axis labels and a title. You’ll notice that I actually cheated and did a little bit of formatting in the code: I added padding between the title and axis labels and the graph, and I got rid of the tickmarks on the right and top sides of the graph. This is because these are not settings that can be affected by the matplotlibrc, so it is unavoidable to include them.

The results for this code are below. It is fraught with problems. Most obviously, the colors are unpleasant and more importantly unclear. Because the bar objects and the error bars are the same shade of blue, the lower half of the error bars become invisible. Furthermore, the line that is overlaid is narrow and a difficult shade of green that is particularly unpleasant when overlaid above the blue of the bars. The axis labels are also problematic. First, they are too small and as a result difficult to read. Further, the special formatting (such as use of greek letters and superscripts) uses a distinct font compared to the rest of the text, which makes the labels even more difficult to read.

Before updating the matplotlibrc

In order to highlight the ugliness of the default color cycle in python, I have attached a second, simpler piece of code and its output:

import numpy as np
import matplotlib
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
for i in range(10):
    y = [np.sin(datum**2+i/10.0) for datum in x]
    ax.plot(x, y)
ax.set_title("Color Cycle, demonstrated", y=1.05)
ax.set_ylabel(r"$sin(x^{2}+\lambda{})$", labelpad=5)
ax.set_xlabel(r"x", labelpad=5)

This code draws a lot of lines which become closer and closer to each other.

Before updating the matplotlibrc

The linewidth problem is apparent here, but just as apparent is the inappropriateness of the high-contrast default colors.

Writing a matplotlibrc to fix things

Matplotlibrc files work by adding settings to a text file in the format option_name: option. I made changes to less noticeable things like the backend and the display size and resolution, as well as turning on the “autolayout” option that I find makes much better use of the available space, but in terms of the major problems I discussed above, I made changes in 5 main areas.


The first thing I did with the lines was to increase the linewidth, so that the lines have a nice weight. Additionally, I turned on anti-aliasing, and introduced rounding at the line edges. In addition to the changes in color detailed below, the effect is quite dramatic. These changes also apply to error bars, and the readability improvement for those is dramatic.


I introduced a new color cycle, taken from this blog, which in turn took it from Stephen Few’s book “Show Me The Numbers: Designing Tables and Graphs to Enlighten”. This color wheel applies to objects such as lines and error bars. It brings colors much closer to the pastel range, and they sit next to eachother well without creating bad contrast, while still being readily distinguishable. Combined with the improvements to the line shape, the effect is a much clearer, softer line compared to the narrow, harsh colored lines of the default settings.


I gave the bars in barcharts and other such shapes a light grey color, which stands out while also allowing other objects such as error bars to be overlaid very clearly. I gave them a thicker, darker grey outline, which gave them a softer gradient than the default black outline. Overall, these objects play very well with the grid, line and error bar overlays, and overlaid text (not shown).


I made significant changes in the font. I immediately increased the font size for the axis labels and the title, to 18 and 24 points respectively. With the increased DPI (discussed above) the effective font size is significantly larger. I also adjusted the font selection to be more math-friendly, so that I could accomplish my second goal: making sure that the mathtext (for things like superscripts) looks identical to the normal font. Right now, Arial is the first preference for fonts, followed by helvetica. Changing to a serif font in the script will continue to use math-friendly fonts. Overall, the text is much more consistent looking and much more clear. Math displayed in the arial font is not as pretty, in my honest opinion, as the defaults, but the continuity with the rest of the text is worth the sacrifice.

Grid and Tickmarks

I turned the tickmarks to face outwards instead of inwards. This has a few effects, including giving clearer marks in particular in busy areas of the graph, as well as placing more spacing between the tick labels and the chart itself. I also further added to the padding between the tickmarks and the tick labels. To extend the tickmarks inwards to the graph itself, I turned on the grid, gave it a very light gray color, and placed it behind all other objects drawn on the chart.

The results

These are the same scripts as above, run with the new matplotlibrc and no other changes. I am very happy with the output, although no doubt I will continue to tweak it as time goes on! I would appreciate feedback as always. Again, like I said above, you can find the matplotlibrc at my github page. Contributions are welcome there as well as in the comments.

Before updating the matplotlibrc

Before updating the matplotlibrc