Custom operations table compute

Trying to evaluate values in columns 1 and 2. If value in column 2 is larger than value in column 1 then column 3 should be +. else if value is larger in column 1 it should be -.

Then a second round where values in column 1 and 2 are swapped if column 3 is -.

Dont understand the syntax in the custom table operation. Need some help.
Anyone have some tips on how to do this?

1 Like

Hi @Roger_Meisal

Do you mean the Datamash tool?

The tutorial below covers a bunch of data manipulation examples. Some include the Datamash tool plus other tool are covered. Often, similar manipulations can be done with different tools, so use these examples as a starting place.

Your query will probably use more than one tool – or the same tool a few times – but those could be grouped into a workflow for reuse. And, if you β€œbookmark” that workflow on your Workflow listing, it will show up in your tool panel view.

Hi @Roger_Meisal
try Text reformatting with awk.
Adding + and -:

{
if ($2 > $1) {print $0,β€œ+”} else {print $0,β€œ-”}
}

Swapping columns and adding + and -:

{
if ($2 > $1) {print $1,$2,β€œ+”} else {print $2,$1,β€œ-”}
}

If the same value is present in c1 and c2, the output gets β€œ-”
If you are after intervals in BED format, make sure the start coordinate uses zero offset, and the is one based.

Hope this helps.

Kind regards,

Igor

1 Like