Dynamic graphs from frames using Networkx - networkx

I partitioned a large dataset of tweets in time-based slices and I created 1 graph per each slice.
How can I create a dynamic graph using the slices as "frames"?
I can do it using Gephi, but it is a manual process.
Thanks!

Visualize dynamic graphs is a complex topic and there's of course not a silver bullet for that.
There are different techniques out there and each library offers a different solution for such problem.
Once of the most common techniques is to combine two visualization components to show the graph in a particular "time frame" and a filter bar to slice / aggregate / navigate in time.
The filter bar an have multiple declination but one of the common pattern is a Time bar (either with line or histogram).
Where I work we recently did a webinar about this topic and offered our solution to it. Here's the link with slides and video.
Disclaimer: to watch the video there's a form to fill. But the slides are publicly available.

Related

FusionCharts/FusionTime stepline chart leaves off data points and binning aggregation distorts the data

I'm trying to reproduce a Pillow app timeline chart using FusionTime. Pillow tracks sleep quality and the different sleep stages using Apple Watch. The following is an example chart:
example Pillow chart
From the app you can export a json file with the data points. For example:
"sleepStageDataPoints": [
{
"stage": 1,
"timeStamp": 673239278.32947648
},
`Stage legend: 0=Deep, 1=Light, 2=REM, 3=Awake
I import the data into mysql, converting the Unix time in the process. I also increment the stage number so that Deep=1, etc., because the axis would be 0 in FusionTime.
So there is a start time and the level of the stage at that time, which remains the level until the next timestamp data point where the stage would change, etc.
Besides this metric, there will be other health related metrics I plan to capture that will model the data in a similar way. Only the starting time and the level at that time, which should remain the same until the next data point.
So that's the general plan. Now the problems...
I'm having trouble figuring out the best way. I think stepline would be the best chart type for this source data. I'm not expecting to be able to have the different stages have different colors. Just being able to see the height differences is sufficient.
But FusionTime doesn't show all of the data points and the ones it does show don't seem to be accurate. I'm blaming data binning.
FusionTime chart
As you can see the first point charted is on May 3rd, 12:24-12:26. But there are 5 data points from May 2nd that it just leaves off. I don't know why. And as you can see from comparing the two charts, the patterns don't match. For instance at 1am the Fusion chart says the level would be REM (3), but if you look at the Pillow chart, it would have to be either Deep (1) or Light (2). Looking at the data points in the database confirms that.
So it has to be the data binning aggregation that is changing the chart. I've tried every aggregation other than average and none of them makes a difference.
I'd like for the data to be 100% time accurate. I want to see every datapoint and not have the first ones disappear. If I mouse over 1am I should see the correct stage level for that time. As I zoom in or out, I'd like the columns to get more wide/narrow as appropriate, but the height should never be wrong. If I zoom too far out, I'd rather the data disappear than be wrong. I'd be fine to lock the zoom level if necessary, not that I know how to.
Is this possible with FusionCharts/FusionTime? Would there be a better chart type to accomplish what I'm trying to do? Is there a different charting software that would do this? I want to use FusionTime, because I want to have the multivariate charts to compare multiple metrics along the same timeline. And I do want to be able to zoom in and out because other metrics I'm tracking wouldn't be limited to this time frame. So I need to be able to zoom/scroll through the entire day.

How can I filter over a bar graph data while showing the average of the entire data set?

I am making an interactive dashboard in Tableau that looks something like this:
https://public.tableau.com/app/profile/monica.ionescu/viz/ExploringHIVStatisticsinSouthAmerica/Dashboard1?publish=yes
(for your best viewing experience, please view the dashboard in the fullscreen view - button on bottom right corner of the board)
I need some help with the bar chart.
I currently have a reference line in place to mark the two averages so that they don’t move as I filter through data. When using the average line feature, the filters on the left change all the graphs on the dashboard in real-time (and thus the average with it). So, it seems like the average line is built from the data points currently on display rather than all the data points in our data set.
I want to show the averages on the bar graph as they are in the image (a constant for the whole data set) without having to manually set the average each time I add/update the data.
How do I make it so that when I change the filters, the bar graph changes but the average stays constant?
Thank you so much!
You can self-blend the data sources - duplicate the data source, but DON'T join any fields/set up relationships. The lack of join can make the secondary source act as a constant.
Alternatively create a FIXED calculation to calculate the average. This should also act as a constant - just make sure none of your filters are in context.

Feed multiple images to CoreML image classification model (swift)

I know how to use the CoreML library to train a model and use it. However, I was wondering if it's possible to feed the model more than one image in order for it to identify it with better accuracy.
The reason for this is because i'm a trying to build an app that classifies histological slides, however, many of them look quite similar, so I thought maybe I could feed the model images at different magnifications in order to make the identification. Is it possible?
Thank you,
Mehdi
Yes, this is a common technique. You can give Core ML the images at different scales or use different crops from the same larger image.
A typical approach is to take 4 corner crops and 1 center crop, and also horizontally flip these, so you have 10 images total. Then feed these to Core ML as a batch. (Maybe in your case it makes sense to also vertically flip the crops.)
To get the final prediction, take the average of the predicted probabilities for all images.
Note that in order to use images at different sizes, the model must be configured to support "size flexibility". And it must also be trained on images of different sizes to get good results.

Tableau and modified Sankey diagram

I have been trying to recreate a modified Sankey based on Adam's work with the American Whiskey Viz and Beatles Analysis Viz that are found here:
https://public.tableau.com/s/gallery/beatles-analysis
https://public.tableau.com/s/gallery/american-whiskey-wheel
I am trying to create the same effect on my own data set. I am not sure how Adam was able to line up the sankey portion with the bar chart perfectly. I have tried many different ID2 field configurations and varying metric fields in the Curve calculated field options with no success. I haven't been able to get them to line up exactly. I would also like my bases to start in different locations along the sankey and not all originating from the left.
I realize that the examples are working with much smaller data sets but believe that this should still be possible with my data. I have tried Business ID in my curve formula and wondering if I need to have a more generic metric in my model. Andy uses Song ID which is a number between 1 and 45. My IDs range from 3-3000. You can see in the workbook attached how I am setting up these fields to get the curve of the Sankey. Is it possible to get them to line up with the barchart at the top of Dashboard 2?
UPDATE 3/22/16:
I was able to get the lines much closer to their bars by modifying the Curve-LoyaltyID2 field. I loaded it to Public for easier viewing. Some lines are still not aligning directly to their corresponding bars though.
Tableau Public
Thanks for any ideas you have!

Plotting metabolic networks?

I need to draw a map of the core metabolism of E.coli. Associated with each reaction in the map I have a number that indicates the flux through this reaction. I want the map to reflect these fluxes through the color of each reaction in the map.
I have tried using tools like Mathematica and Cytoscape, but it is very hard to get a nice layout of the metabolic network. I have seen maps of E.coli metabolism which look very nice on paper. What I need is a map like these, but where I can define the colors of the reactions.
There are some tools available, for example, metdraw.com. But when I upload my E.coli SBML model, the plot layout is a disaster. There used to be a web IPython notebook that one could use for some prebuilt models, where you just had to input the reaction fluxes. But now it's gone: http://nbviewer.ipython.org/github/opencobra/cobrapy/blob/master/documentation_builder/visbio.ipynb
See the image below for an example. Forget about the yellow bounding boxes delimiting compartments. I can spare those.
Some tracking of the broken link you posted brings me to Escher, which appears to be what visbio is now called:
https://github.com/zakandrewking/escher
For example see:
https://cobrapy.readthedocs.org/en/latest/escher.html
Escher is part of Cobrapy:
http://opencobra.github.io/cobrapy/
A software suite to model biological networks.