PoisonAlien / trackplot

Generate IGV style locus tracks from bigWig files in R
140 stars 16 forks source link

Averaging replicates and other mathematical operations #4

Closed dgoekbuget closed 3 years ago

dgoekbuget commented 3 years ago

Hi, Thanks for this useful efficient tool. I was wondering whether it is possible to average (or e.g. subtract) tracks from each other? Also, is it possible to group autoscale defined subsets of tracks as opposed to all tracks shown? Thanks

PoisonAlien commented 3 years ago

Hi, I think both of the issues are doable. I will make the changes and let you know once it's done. It might take some time.

PoisonAlien commented 3 years ago

Hi, Sorry for the delay. I have implemented an additional function track_summarize which can average the signals by condition. You just need to run this function before calling the plotting function.

track_extract()  -> track_summarize() -> track_plot()

Unfortunately, subtracting part is bit tricky so I didnt do it. But I think you could just take the output from the track_extract() and subtract the values under the column max for your samples of interst. It should work just fine.

Hope this helps..

edit:Now there is a groupScaleByCondition in track_plot. Groups are identified by the samples belonging to the same colors (as defined by col).

dgoekbuget commented 3 years ago

Works great! Will make sure to cite you in my paper!

dgoekbuget commented 1 year ago

The groupScaleByCondition seems deprecated. How to define groups for groupAutoScale?

PoisonAlien commented 1 year ago

Hi,

I have changed a few things in recent updates. Example:

u87_bigWigs = list.files(path = "data/U87/", pattern = "\\.bw$", full.names = TRUE)
u87_bigWigs = read_coldata(bws = u87_bigWigs, build = "hg19")

# Add any number additional metadata to your coldata
u87_bigWigs$treatment = c("dmso", "treat", "treat")

u87_bigWigs
                     bw_files bw_sample_names treatment
1:          data/U87//BRD4.bw            BRD4      dmso
2: data/U87//BRD4_dBET_24h.bw   BRD4_dBET_24h     treat
3:  data/U87//BRD4_dBET_2h.bw    BRD4_dBET_2h     treat

# Extract signal by gene or loci
te = trackplot::track_extract(colData = u87_bigWigs, gene = "BCL6")

# summarize by condition of interest
te_s = trackplot::track_summarize(summary_list = te, condition = "treatment")

# plot
trackplot::track_plot(summary_list = te_s)

I hope this helps. Please let me know if you encounter any issues.