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

107 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 One

The class will cover how to install and use Bioconductor software. We will discuss common data structures, including ExpressionSets, SummarizedExperiment and GRanges used across several types of analyses.

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

Bloomberg School of Public Health

Now we're back with the second part on the use case and how to combine GRanges and

Â AnnotationHub.

Â As a quick reminder, we have gotten hold of our promoters.

Â Our promoters we'd say is a GRanges thing.

Â We have 50,000 promoters.

Â We have gotten hold of our histone modification peaks.

Â We have roughly 75,000 of those.

Â And we're now going to ask is this particular histone modification,

Â H3K4 trimethylation, enriched in promoters?

Â So, to do that, we want to use,

Â we basically want to see how often do they overlap?

Â And the workhorse for that is findoverlaps,

Â which is a function we'll use again and again.

Â So let's ask how many promoters all have a peak?

Â We get this overlap object out, but

Â I'm really mostly interested in how big a percentage of the promoters overlap.

Â And here,

Â as we have explained with findoverlaps, we have to think about double counting.

Â We can take the query hits, we can do a unique.

Â So let's see a length, let's first save the file overlaps.

Â So this is the number of peaks that overlap, length(unique) because

Â we don't want to double count queryHits(prompt).

Â This is the number of

Â promoters that have a peak in them, and

Â the number of peaks that have a promoter in them, we get with the subject hits.

Â I often do a little trick here.

Â I utilize that we have the convenient function called subsetByOverlaps,

Â where, say, out of my peaks, how many overlap a promoter?

Â And perhaps we want to ignore strand.

Â And then I say what's the length of that?

Â That's the same number as before.

Â And then I divide that by length of the peaks.

Â This is the percentage of peaks that overlap a promoter.

Â Now 30%?

Â Is that big or little?

Â It's not 100%.

Â It turns out if you know a little bit more about H3K4 trimethylation,

Â is that this histone mark doesn't just mark actual promoters.

Â It's also sometimes associated with enhancers and other regulatory elements.

Â So 30% is perhaps pretty good.

Â Is it?

Â Well, we have to do a little bit more analysis in order to answer that.

Â Let's first answer like how many promoters actually have a peak in them.

Â So that requires us to switch the promoter and the peaks.

Â And we have to divide by the length of the promoters.

Â And we get a number which is basically 50%.

Â That's pretty nice.

Â My rule of thumb, is that in any given cell types, 50% of genes are expressed.

Â And that fits pretty well with this 50% we see here.

Â It's probably a little bit of coincidence, but you

Â have to accept that in many cell types, a lot of genes are not being expressed.

Â So this system modification should only map actual promoters,

Â which is going to be a subset of all the promoters.

Â Now, is this big or not?

Â Let's look a little bit about the actual, let's look at how big are the peaks and

Â how big are the promoters we have and how big is the intersection.

Â So, let's do a, let's say how many paces does the peaks really call?

Â We ignore strand in this reduce.

Â And I want to have it in megabases.

Â So 11 megabases.

Â How many megabases does the promoters call?

Â 62 megabases.

Â And, how big is the overlap?

Â So, here we take the intersection of the peaks,

Â and the promoters, and we ignore the strand again.

Â And we say sum, width, and divide it by a million.

Â That seems to be wrong.

Â I'm not dividing by a million, I am dividing by 106.

Â 3 megabases.

Â So all of this is like small parts of the genome.

Â 11 megabases, 62 megabases, 3 megabases.

Â But again, is it big?

Â So, by the way, when I'm doing this intersect here between peaks and

Â promoters I don't have to call reduce on it,

Â because I know that the output of intersect is a normal R ranges.

Â So I don't get anything out of calling reduce on it.

Â Now, in order to do this, let's quantify the relationship between these things.

Â And we've got to do a little back of the envelope calculation that's useful.

Â But I wouldn't say it's a perfect

Â statistical answer to the question of whether or not the overlap is significant.

Â We've got to basically say that we've got 3 billion bases in the human genome.

Â And a base can either be both in a peak and in a promoter, or

Â it can be in a peak and not in a promoter and vice versa, and

Â we're going to look for is there some kind of significant enrichment here.

Â We're not really going to do significance.

Â We end up with a two by two table.

Â But we are going to look at the art range who has the strength of the association.

Â Now, let's construct our matrix.

Â It's going to be a 2 by 2 matrix that's filled up with zeroes.

Â And we're going to have the colnames and

Â the rownames they're going to be in and out,

Â those are colnames, and the same thing for the rownames.

Â So now we have the matrix and ready to fill out.

Â So in in, is going to be the number of bases that

Â That are part of both of the things.

Â So that's really the intersect,

Â the sum of the basis here we have in the intersect command.

Â We've gotta put that up in element 1,1.

Â So we're going to have peaks on the rows and promoters on the columns.

Â So now I'm going to take in,out, 1,2, and

Â this is going to be the bases that are in peaks but not in promoters.

Â So we can do in a setdiff.

Â Also it should be in the peaks, not the promoters.

Â Need to ignore the strand.

Â And this was as a Grange so we want to have the sum of the width, and again I'm

Â using that my setdiff is a set operation, so I get a normal R ranges out of it.

Â And we're going to do the same thing, but

Â we are going to reverse peaks and promoters.

Â So we can do the colSums of in, out, and

Â now we get the 62 million we dad before,

Â and if we do the row sums, We get the 11 millions we had before.

Â Now, we need to fill out the last thing, and that's really the number of bases

Â in the human genome that is not part of any of these things.

Â So that's really equal to, let's say the human genome is 3 billion bases,

Â And we are going to subtract sum of inOut.

Â Yeah, we will just subtract sum of inOut because we have a zero down in

Â the lower-right corner.

Â So we now have a 2 by 2 table and we can compute an out range for this table.

Â Normally you would be able to compute an out range using the Fisher

Â test function in R, which starts a Fisher exact test.

Â So the way you do this would be fisher.test of inOut.

Â And you want to get the component called the statistic.

Â I happen to know this.

Â But now because we have entries that sum up to the length of the human genome and

Â that's bigger than the biggest integer, we get an overflow problem.

Â So now we have to compute the odds ratio by hand.

Â Now, I always get confused about that so I have to look it up in Wikipedia.

Â But really it's equal to the product

Â of the Of the two columns divided by the,

Â so let's see if it came out.

Â So this is the diagonal, one diagonal

Â So the odds ratio is a number between zero and

Â infinity, and values greater than 1 means enrichment.

Â So this here means that The overlap between the peaks and

Â the promoters is like 18 fold more enriched than we would expect.

Â Now this is actually very driven by the size of the human genome.

Â So we just put in like a number which we said was 3 billion, and

Â you can argue, is that really the right number?

Â So this has to do with giving a good statistical answer to this entire thing.

Â It turns out that while the human genome has 3 billion bases,

Â some of these bases can't be mapped using short read technologies.

Â Some of the bases haven't even been sequenced.

Â So it's probably wrong to say that the mappable part of

Â the human genome is 3 billion.

Â [COUGH] We can do a sensitivity analysis and

Â see how much does this odds ratio change if we dramatically change our assumption.

Â So let's say that only half the human genome is mappable.

Â That's probably an underestimate.

Â So, let's set inOut, the 2,2 to be zero first,

Â and then we say inOut[2,2] = 1.5

Â times 10 to the 9- sum(inOut).

Â Okay, now we are back, but we have a much smaller genome.

Â [COUGH] Let's compute the same odds ratio.

Â And we can see that this really dramatically reduced the enrichment but

Â it's still much, much bigger than 1.

Â So while the size of the human genome on the mappable part of the human genome

Â definitely has some influence on what is the quote,

Â true odds ratio for this analysis, [COUGH],

Â it doesn't seem to change our conclusion that you have some amount of enrichment.

Â You would like to put a p-value on this doing a Fisher exact test like here,

Â turns out that because the numbers are big, everything is significant.

Â That's kind of a problem with Fisher exact test, when you use it on tables with very

Â big numbers, so this is for sure very significant.

Â But you can argue is this even the right analysis?

Â We are letting each base independently

Â either belong to the peak region or the promoter region, and

Â is that really the right model for this type of phenomena?

Â That's probably unlikely, but I would say that this back of the envelope calculation

Â we're doing here suggests that there is some enrichment.

Â It may not be that the odds is precise 8.9 or 18.3.

Â It may be a different number, but

Â there's probably some amount of enrichment happening here.

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