Comments (9)
Thanks so much! And oh I'm not computing confidence intervals for the observed data, although I maybe I could using a bootstrapping procedure, maybe I should try that... I'm merely trying to add standard deviation bars to the expected bars which are generated from a null model.
from complex-upset.
@VirtualSpaceman you did all well, it is just that there were many changes since version 0.4.0 and that code does not work any more. I will look into that.
from complex-upset.
Thank you! Sure, I would approach it like this:
upset(
observed, sets,
base_annotations=list(
'Intersection size'=upset_annotate(
'..count..',
list(
geom_bar(
aes(fill='observed'),
width=0.35,
position=position_nudge(x=-0.2)
),
geom_bar(
data=expected,
aes(fill='expected'),
width=0.35,
position=position_nudge(x=+0.2)
)
)
)
)
)
As an exmple:
observed = data.frame(
a=c(TRUE, FALSE, FALSE, TRUE, TRUE),
b=c(TRUE, TRUE, TRUE, FALSE, TRUE),
c=c(FALSE, TRUE, TRUE, FALSE, FALSE),
d=c(FALSE, FALSE, TRUE, FALSE, FALSE)
)
sets = c('a', 'b', 'c', 'd')
then if you have expected counts as a list, create a data frame (each intersection is represented as hyphenated character/string):
expected_summary = data.frame(
exepcted_count=c(
'a-b'=3,
'b-c-d'=1,
'b-c'=1,
'a'=0
)
)
expected_summary$intersection = rownames(expected_summary)
expected_summary
and transform to counts format:
expected = expected_summary[
rep(seq_len(nrow(expected_summary)), expected_summary$exepcted_count),
1:2
]
expected
You can get the intersections data using upset_data()
on your data.
Would that work for you?
from complex-upset.
Yes I think that will work. Thanks so much for the quick reply.
from complex-upset.
I got it working with my data, thanks again! One last thing. I'm having a hard time adding a geom_errorbar to the expected bars. When I add it gets added to the set intersection dot part on the bottom.
from complex-upset.
This is due to the order the plots are assembled - the "dots matrix" is the last one added. With multi-pane plot I had to create a bit different interface (inspired by ComplexHeatmap among others) which requires to specify where the geom should be added. For geom bars one could do:
intersections_data = upset_data(observed, sets)
intersection_sizes = unique(
intersections_data$with_sizes[, c('intersection', 'intersection_size')]
)
intersection_sizes
confidence_intervals = binom::binom.confint(
intersection_sizes$intersection_size,
nrow(observed),
method='wilson'
)
confidence_intervals$intersection = intersection_sizes$intersection
confidence_intervals
upset(
observed, sets,
base_annotations=list(
'Intersection size'=upset_annotate(
'..count..',
list(
geom_bar(
aes(fill='observed'),
width=0.35,
position=position_nudge(x=-0.2)
),
geom_bar(
data=expected,
aes(fill='expected'),
width=0.35,
position=position_nudge(x=+0.2)
),
geom_errorbar(
data=confidence_intervals,
aes(
ymin=lower * nrow(observed),
ymax=upper * nrow(observed),
y=NULL # overwrite the default y=..count...
),
width=0.2,
position=position_nudge(x=-0.2)
)
)
)
)
)
It might be also interesting to apply this to intersection ratios.
Can you share how you calculate the confidence intervals? I would be curious to learn!
I just saw that you mention the expected bars (which might make more sense) - but the relevant code is easy to adjust I guess.
from complex-upset.
Hmm would there be a way to directly enter the intersect size counts for my expected bar? When trying to add the SEMs as a geom_errorbar the ymin/max arrays need to be as long as the input observation data which doesn't make sense to me. I have 62 bars for 62 different set intersections but it wont let me put in an array of length 62.
from complex-upset.
from complex-upset.
Hi,
I tried to reproduce the exact plot according to Mike's instructions and code, but I couldn't. I'm getting the output in below.
As this issue is from last year, maybe some internals have changed and this way doesn't work anymore. As I'm a newcomer in R programming language, I would like to ask: which modifications should I do to reproduce the double bar plot?
Thanks.
from complex-upset.
Related Issues (20)
- complex-upset for multiple lists HOT 2
- How can I change the labels in the UpSet plot? HOT 10
- Is there a way to speed up ComplexUpset for large data sets?
- Removed rows due to "missing values" when there are non HOT 2
- How to display intersection size as percentage of total rows?
- What determines the size of the bars? HOT 3
- How can I reduce the file size of the .eps UpSet figure?
- upset error: `strip.clip` not defined HOT 2
- Reduce the size of circles when the size of the global figure is diminished. HOT 2
- ! `data` must be uniquely named but has duplicate columns HOT 1
- How to use fromexpression() of upsetR in complex upset? HOT 1
- sort_sets user order HOT 1
- Change axis text size and bar text size HOT 1
- Incorrect intersection size HOT 8
- Memory issue when passing "intersection=" parameter to large matrix HOT 1
- Add more examples
- add intersection of the union of certain sets within the same intersection upset plot. HOT 2
- Set default color of dots in the matrix plot HOT 1
- Ordering by intersection sizes and degree
- y axis units for the intersection size and stacking plots HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from complex-upset.