Learn to use tools from the Bioconductor project to perform analysis of genomic data. This is the fifth course in the Genomic Big Data Specialization from Johns Hopkins University.

Loading...

From the course by Johns Hopkins University

Bioconductor for Genomic Data Science

123 ratings

Learn to use tools from the Bioconductor project to perform analysis of genomic data. This is the fifth course in the Genomic Big Data Specialization from Johns Hopkins University.

From the lesson

Week Two

In this week we will learn how to represent and compute on biological sequences, both at the whole-genome level and at the level of millions of short reads.

- Kasper Daniel Hansen, PhDAssistant Professor, Biostatistics and Genetic Medicine

Bloomberg School of Public Health

In this session, we will discuss RLEs or

Â run length in coded vectors from GenomicRanges.

Â Run length encoding is a way of representing very long vectors.

Â Where some elements are the same.

Â This is a form of compression of the very long vectors.

Â Whether or

Â not the compression works depends on the type of data we're looking at.

Â This type of compression is particularly interesting for

Â representing signal over the genome where the signal is only

Â non-zero in a small part of the genome.

Â That's true, for example, for

Â on a sequencing where we are only supposed to have signal over transcribe regions.

Â It's true for ChIP sequencing, and it's true for many other applications.

Â The standard example of an ollie in genomics is a covered vector.

Â A covered vector is something that comes out of high throughput sequencing,

Â and it details for each space in the genome,

Â how many short reads covers that particular base?

Â Okay, enough talking.

Â Let's see some examples.

Â It's going to be a little bit easier to see in practice.

Â Let's first, load the library.

Â Now, let's construct an ollie which we do with the capsule RLE constructor.

Â So we take a single vector.

Â And we get the RLE out.

Â So let's look at it.

Â So what it has done now is, it says, this vector starts off with 6 with the value 1.

Â And the value 1 is repeated 6 times.

Â Then the value 2 is repeated 5 times.

Â The value 4 is repeated 2 times.

Â And finally, the value 2 is repeated 1.

Â So here we can see, we have something called lengths.

Â We have something called values.

Â And the access them using one length, Of RL and

Â run value, Of RL.

Â This is just a way of compressing the vector.

Â And this is a compression, in this case here,

Â because we have taken 14 numbers and compressed them into 8 numbers.

Â So this compression makes sense,

Â if the same number occurs in the vector right after each other.

Â We can take our RL code and vector and

Â then convert it back to a normal vector term by s numeric.

Â We get the original vector out.

Â There's also something to make the confusion total.

Â There's something in base R called RLE which is

Â also run length encoded, a run length encoded vector.

Â But it has a completely different API.

Â So often you shall think about this.

Â You have your run length encoded vector which is now,

Â coverage of signal across inside genome.

Â And very often, you have one or two aberrations where you have a set of

Â genomic regions and you want to do something over that.

Â So let's simulate that.

Â You do this with the aggregate function.

Â But let me tell you an example.

Â We take an Iranges.

Â Let's say that start is going to be 2 and 8.

Â And let's say the width is equal to 4.

Â So this gives me a certain subset of the r lead.

Â And I can now aggregate.

Â I take my one and encode a vector.

Â I take my Iranges.

Â And as my function, I could take the mean.

Â I get two numbers back and

Â this is the mean of all the elements that are in the two different ranges.

Â So, it's a mean of, let's say we take our original vector.

Â We got that by saying as numeric of RL.

Â And we take the mean of vector 2 to 5, vectors 2 to 5.

Â Mean of that, and from 8 to 11.

Â So this could, for example, compute average signal

Â across a set of pre-specified genomic regions of a coverage vector.

Â You can construct a coverage vector out of Iranges, that can be useful sometimes.

Â So, let's say you have Iranges.

Â Let's make a new Iranges.

Â So I have these overlapping intervals, and I can say what's the coverage of this?

Â By which, I mean, how often for integer number 1?

Â How many of these ranges is a part of for integer number 2?

Â How many of these ranges is a part of.

Â And I get this run length encoded vector that goes like first,

Â 1,2, and then it's 3 for a little while, and then 2, 1.

Â Because of the structure of our Iranges.

Â Of course, I could do this with GRanges and genomic intakes,

Â and we've got a lot of that a little bit later on.

Â Sometimes you have covered rate.

Â So you have an ollie.

Â And you really want to figure out areas where this vector are big.

Â And I want to get that back into like intervals.

Â The way you do that is you use a slice function.

Â So you can think of the coverage function as giving you kind of a functional on

Â a chetum and now we slice the top off.

Â So let's take our ollie from before.

Â And let's slice it at a value of 2.

Â So now, we get a view spec, but let's ignore the views for a moment.

Â We get a single integer from 7 to 14.

Â And these are all the positions.

Â And in this case, there's a single interval containing all of the system

Â whether vector is greater than 2.

Â Greater than or equal to 2.

Â We can do the same thing with slicing it at a little bit hold.

Â I often, will we get a much smaller interval.

Â So we got bag of use object.

Â And this is completely, the same, and either way, exactly ,the same as the views

Â object which we have discussed for BS genome objects.

Â So we have one potentially very big object with just a one length encoded vector.

Â Think about vectors across the entire genome.

Â And we basically, have intakes or

Â intervals which subsets this very long beta.

Â And we do that using this views constructor.

Â But now, instead of a view in a genome.

Â We have a view run length called a vector.

Â We can instantiate our own views, of course.

Â And, once we have a view, we have a set of views.

Â Let's make a set of views.

Â We can compute functions on these views here.

Â For example, let's say, we just want to take the mean of the view.

Â And this is basically,

Â the same as what we did with the aggregated sample [INAUDIBLE].

Â Let's do the same thing with GenomicRanges.

Â Instead of Iranges, not everything is in chromosome 1 and we do a coverage of that.

Â There was a little bit of quick typing, and we now get back something

Â called an RLE list, because we have one RLE for each chromosome.

Â In this case, we just have a single chromosome.

Â But if it was normal human data, we would have many more chromosomes or contexts.

Â But here it's a single one, and inside of that we have an RLE.

Â When we have genomic range like this on our RLE list like this.

Â We can, again, instantiate a view on it.

Â And now we give it, let's say,

Â Yeah, let's view it on the Granges we had before.

Â No, let's view it on like Granges.

Â Chromosome 1 [INAUDIBLE].

Â So now we get an error back.

Â It says that, the ranges list must be a RangesList object.

Â This is a type of object we haven't discussed from genomic ranges, but

Â aside from Granges.

Â There's this thing called RangesData, RangeData and

Â RangesList that really are more.

Â They were an attempt at providing a Grange like object.

Â It was by some accounts successful, but hasn't really stuck around.

Â We still see these objects being around here and there.

Â So the way really solve this is you.

Â So you take this Grange and you just like say,

Â okay, let this be, let this be a range of lists.

Â And now, we have this views list, and let's take what we see in chromosome 1.

Â And now, we have a views, exactly as we wanted from persistent 3 to 7.

Â It's a little weird the Granges doesn't work direct as input interviews.

Â I will consider that a kind of a balk and

Â I'm definitely going to discuss that with the Bioconductor people.

Â So now, we have learned about running the code of vectors.

Â We have learned that we can have them both on the integers, but

Â we also can have them on the genome.

Â We can also have run.

Â We don't just need to run length encoding of integers.

Â We can have run length encoding of logicals, or even characters,

Â or logicals.

Â Actually, come to speak of it, if we look at a GRanges.

Â You can see that the seek names of the chromosome names are.

Â We can now recognize that these are one length encoded vectors.

Â Because we often have all the ranges in chromosome 1 next to each other.

Â We learned about how to compute on them using aggregate and views.

Â [COUGH] We have learned how to convert a Granges into our lead by conference.

Â And we have learned we can slice off the comps.

Â Coursera provides universal access to the worldâ€™s best education,
partnering with top universities and organizations to offer courses online.