« first day (2193 days earlier)      last day (2288 days later) » 

1:38 AM
Can someone say, why this isn't working?
SeedRandom[1234];
RandomInteger[4, 20] /. Longest[match : 0 ..] :> {match}
What I want is all neighbouring zeroes are pulled together in a list.
 
 
2 hours later…
3:38 AM
:42367038 Yes, but I need all sequences of zeroes.
 
i realized it the moment i clicked send, sorry for the false alarm :-(
 
Hehe.. no problem.
The thing is, I know why it doesn't work, but I believe it should work.
 
then tell me, why doesn't? it seems it stop after the first sequence that match the pattern
if you have time, of course
 
@Alucard The question comes down to why you can write
{1, 2, 1, 1, 3, 2} /. 1 :> "Match"
but you cannot match several PatternSequences.
" {1, 2, 1, 1, 3, 2} /. PatternSequence[1,3] :> "Match
In the last case, you always need to match the whole expression.
{1, 2, 1, 1, 3, 2} /. {start___, PatternSequence[1, 3], end___} :> {start, "Match",
   end}
The first example should read
{1, 2, 1, 1, 3, 2} /. PatternSequence[2, 3] :> "Match"
 
3:59 AM
then why do you think longest should work ? if i can't match patternsequences without matching the whole expression longest will fail
he see repeated zeros
am i wrong?
 
@Alucard No. I was hoping there is a simple solution to this.
 
4:20 AM
ah ok. side note: i don't know how ( seriously) but i ended up being asked to make a machine learning algorithm (unsupervised learning) that detect Tads from a slightly modified Hi-C matrix... i mean what the fuck! any advice for a noob like me?
i already have the program that generate the matrices and i already know what function to apply, but i would like to know if there is some example available on the internet from where learn
something similar, not necessarily related
 
4:49 AM
@Alucard I don't know what an Hi-C matrix is. What is your input data? N matrices, and you are looking to find groups of matrices which are similar?
 
5:04 AM
@Alucard I assume you've also seen this: ncbi.nlm.nih.gov/pmc/articles/PMC5686814
It seems to be (at least related to) what you want
But just not in Mathematica
 
5:18 AM
ah right i forgot to say it but i have to use python. ClusterTad is similar to what i need but it's written in java or matlab. the think is i have small experience with machine learning (simple stuff like perceptron,adaline) but i have never put my hands on an unsupervised algorithm.I was planning to take my time and learn from scratch but my mother got hospitalized few weeks ago and i lost time.
@b3m2a1 my hope was to find some free example on internet of an unsupervised ml algorithm applied on matrix from where i could learn ( and copy-paste)
i think their measure functions will serve my good haha
*thing
@C.E. one matrix, i must detect particular regions inside the matrix ( often they looks like squares on the matrix) that indicates aa self interacting chromatin region
 
@TimStone Hey Tim. I remember you helped me a lot with the google-prettify highlighter for our site here. I thought about fixing the valid characters for valid variables because atm we support only ASCII. It all comes down that Mathematica supports many valid characters and the regex is huge. I suspect this won't be a problem since the usual suspect A-Za-z would be tested first. If you can spare some minutes or you would like to earn some Mathematica points, please feel free to answer here:
1
Q: Down into the abyss: The UTF-8 hell

halirutanDid you ever wonder why here on our site, there is a highlighting difference between f[argX_] := 1; and f[argα_] := 1; Well, now you know and it's me you can blame. It wasn't an oversight. It was a decision I made on purpose. Mathematica is one of the nowadays growing number of languages t...

 
5:36 AM
@Alucard Off the top of my head, you could create a graph from the matrix by putting an edge between two neighboring elements if they are sufficiently close and then do a CommunityGraphPlot. If that works, then one can find a Python implementation.
 
5:46 AM
@C.E. i don't know how to do what you suggested. the result should be like media.springernature.com/full/springer-static/image/…
 
 
2 hours later…
8:14 AM
@Alucard Well, if the data looks like that then it's easier. You should first do agglomerative clustering on the rows of the matrix and reorder the rows so that rows in the same cluster are next to each other, and then agglomerative clustering on the columns and reorder in the same way.
I actually wrote some code for this a while back using scipy, but perhaps you want to give it a go first. I don't know if this is for a course or what this is.
Correction: You should cluster either the rows or the columns, and then reorder both rows and columns using the clustering. Agglomerative clustering will build a hiearchical tree, and the leaves of the tree will be ordered such that rows close to each other are close to each other in the list of leaves. Therefore, do agglomerative clustering and order the rows and columns in the same way that the leaves are ordered.
 
 
1 hour later…
9:54 AM
@C.E. yes, i think will try and see what i can do with scipy first, thanks. i only knew k-means clustering but i will try to implement this new mathod too
 
 
4 hours later…
1:40 PM
@b3m2a1 is it possible to scope Appearance? e.g.:
Style[
 Panel["Test", ImageSize -> {100, 50}, Appearance -> "Pressed"]
 ,
 PanelBoxOptions -> {Appearance ->
    FrontEndResource["FEExpressions",
     "MoreLeftSetterNinePatchAppearance"]}
 ]
This does not work because Appearance can be a list of rules or a specific key which refers to, exactly, where does it refer to?
 
2:09 PM
@Kuba I've never actually found where the "Palette" and "AbuttingLeftRight", etc. styles are defined so I don't know how to change how Appearance -> "Pressed" and things are defined, if that's possible at all. That said, for your case the general thing I've used (because I saw it used in some WRI paclet code) is to pass the button state as the final argument in your Appearance list. E.g.:
Button["Test", ImageSize -> {100, 50},
 Appearance ->
  Append[
   FrontEndResource["FEExpressions",
    "MoreLeftSetterNinePatchAppearance"],
   "Pressed"
   ]
 ]
It doesn't seem like Panel respects that argument though.
Interesting
One other useful Appearance related trick is the "Disabled" key you can pass, if you haven't seen that one:
Button["Test", ImageSize -> {100, 50},
 Appearance ->
  Append[
   FrontEndResource["FEExpressions",
    "MoreLeftSetterNinePatchAppearance"],
   "Disabled" ->
    Lookup[FrontEndResource["FEExpressions",
      "MoreLeftSetterNinePatchAppearance"], "Pressed"
     ]
   ],
 Enabled -> False
 ]
Only activates when the button has Enabled -> False
 
@b3m2a1 I see, pity, but I didn't know about non key/value element behavior, it actually solves the problem:
Style[
 Table[Button["Test", ImageSize -> {100, 50},
   Appearance -> {ParentList, "Pressed"}], 5]
 ,
 ButtonBoxOptions -> {Appearance ->
    FrontEndResource["FEExpressions",
     "MoreLeftSetterNinePatchAppearance"]}
 ]
@b3m2a1 hmm, it only works for pressed though.
 
2:34 PM
@Kuba huh I guess that's true. Makes it significantly less useful.
@Kuba I've been in email contact with him (walked him through those first debug steps). Just haven't yet had the time to debug the problem completely.
 
@b3m2a1 ok, just wasn't sure you were aware of the topic.
 
3:16 PM
In case someone else is wondering how to show vertex names inside of a graph vertex, and adapt the vertex size to the vertex name, I think this should be quite flexible (even though I'm ignoring the vertex size values):
g = ExampleData[{"NetworkGraph", "EastAfricaEmbassyAttacks"}]

Graph[g,
 VertexShapeFunction -> (Text[Framed[#2, Background -> White], #1] &),
  VertexLabels -> (_ -> None),
 PerformanceGoal -> "Quality",
 GraphLayout -> {"RenderingOrder" -> "VertexFirst"}
 ]
 
 
1 hour later…
4:38 PM
Hey peeps! Was the "Table[expr, n]" syntax added not too long ago? Any idea when?
 
@ChrisK It doesn't work in version 9 and the docs say that Table was updated in 10.2. Therefore, I guess 10.2 is your candidate.
 
@halirutan Thanks!
If you have v.9 handy, could you see if Table[expr, {n}] works there?
 
@ChrisK Yes, it works.
 
thanks again!
 
 
2 hours later…
6:24 PM
If I have an image and an image mask (black with a white ellipse) how to I set everything in the image outside of the mask to be transparent.
Also, crop the resulting image to the bounds of the ellipse
SetAlphaChannel[img, mask]
 
 
2 hours later…
8:30 PM
@Edmund here's the way I thought to do it:
chans = ColorSeparate[img];
mask = Binarize@
   Rasterize[
    Graphics[Disk[{0, 0}, .5], PlotRange -> {{-1, 1}, {-1, 1}}]];
ImageCrop@ColorCombine[ImageAdd[mask, #] & /@ chans];
SetAlphaChannel[ImageCrop@ColorCombine[ImageAdd[mask, #] & /@ chans],
 ImageCrop@ColorNegate@mask]
Force all pixels outside the disk to be uniform by adding the mask
Actually you could do that one better:
ImageCrop@
 ColorCombine[Append[ImageAdd[mask, #] & /@ chans, ColorNegate@mask],
  "RGB"]
 
9:23 PM
The following example from the documentation crashes my kernel (win10 v11.2). Anyone else have this?
data = RandomInteger[100, {1000, 2}];

FindShortestTour[data, PerformanceGoal :> "Quality"] // Short
 
10:05 PM
@b3m2a1 Thanks
 
10:48 PM
The videos of the WTC 2017 (October) are finally out on Wolfram Screencast. Compiler stuff by TWJ is also there :-)
4
 

« first day (2193 days earlier)      last day (2288 days later) »