-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
computation of conditions bug #52
Comments
You are right. Currently IMHO there was a misunderstanding. I asked:
And you said
That's why I thought you don't care whether a bond is covered by one or two fragments and we look for the highest bond coverage (regardless its covered by one or two fragments). But I understand that a bond is covered better by "both" than by a single "N" or "C". I will change that. |
yes, sorry I understood your question in a very convoluted way ... I thought you were asking "why is "both" with low intensity fragments better (gets a score of 2) than N-terminal with high intensity (gets a score of one)". Facepalm. Also now you probably understand why I suggested splitting the table into N- and C-terminal part for computing combinations... Given we have to test both the tables its much simpler to do this separately |
Ok, I changed the function. Now you get a three column matrix (with conditions as bestConditions(n)
# index fragments bonds
#C937.30_5.0e+05_0.0e+00_00.00_28_00_01 4830 72 69
#C703.20_1.0e+06_1.0e+07_02.50_00_21_1 3903 12 11
#C703.20_1.0e+06_1.0e+07_05.00_28_00_2 3945 8 8
#C703.20_5.0e+05_1.0e+06_15.00_00_00_2 2929 4 4
#C703.20_1.0e+06_5.0e+06_15.00_14_00_3 3830 3 3
#C937.30_5.0e+05_0.0e+00_00.00_35_00_07 4847 3 2
#C562.70_5.0e+05_5.0e+06_02.50_28_00_2 1052 2 2
#C562.70_1.0e+05_1.0e+06_02.50_00_14_3 129 1 1
#C562.70_5.0e+05_0.0e+00_00.00_00_14_01 702 1 1 Could you please test again? (Hopefully I don't mess everything up. It is dangerous to code at night ...) |
this is still a problem, and I think I know why. But just to reiterate, when we calculate coverage: both - gets 2 points when you are combining conditions for a particular bond both + both = both - 0 points the part that is wrong in your code is that both + N gets 0 point at least your code seems to perform this way numerically, i.e. when you add a new condition you do not reward having both in the position you only previously had N or C. Might it be smth to do with this x[.row(x[, hc[1L], drop=FALSE]), ] <- 0L here you seem to assign 0 to all rows even if you only had N/C in the bond? |
To be honest I don't completely understand your example. But should it work in the following way? Example data: Matrix:
First round: Select condition C1 (because 2 bonds covered) and return the following:
Now my code does the following (because all bonds are already covered by at least one fragment):
Am I right, that you suggest to degrade B in C2 to C (because N was already present in C1) and keep C in C3 (because bond 2 was not covered by B or C):
So you will get 2 more rounds:
|
sorry I made a mistake in my description, since summing conditions is asymmetrical, as I just realise. From now on lets put already selected condition as the first one, so: both + N = both - 0 points the latter is broken in your code. |
as to your comment: yes Both becomes C when N is already covered. But your code makes Both into nothing. I understand this is confusing so: THE BOTTOM LINE IS WE NEED TO ACCUMULATE AS MANY FRAGMENTS GOING BOTH DIRECTIONS. HAVING A FRAGMENT GOING IN THE DIRECTION THAT IS ALREADY PRESENT GIVES 0. HAVING A FRAGMENT GO IN A DIRECTION THAT IS ABSENT GIVES 1 hence my suggestion to split the table into 2 parts.
|
@pavel-shliaha could please (re)test |
yep, it now works! |
right now the bestConditions() returns a table with the number of fragments covered + index. I know we discussed this and I know I asked for fragments not bonds, but it seems the field requires to maximise bonds not fragments. Could you please now compute both: bonds covered and fragments number and introduce an argument, maximise = "bonds" or "fragments", with "fragments" as default. If "fragments" is selected as in now,the conditions are listed in order of increasing fragments if "bonds" are selected the conditions are returned in order of maximising bonds covered. However metrics are always returned |
I have a question regarding the final reporting table. The current approach is:
The problem is in the implementation of step 2. Image the following conditions:
maximise fragments:
The question is what should be reported for the same problem for maximise bonds is IMHO easy:
|
In your example, the answer we are looking for is
however, what is important attempting to maximise bonds will generate a different optimal combination than attempting to maximise fragments. Hence we need an argument: maximise = "bonds" or "fragments" However in both cases (if possible, I would prefer to have both columns: fragments and bonds) calculated. I know this is not what I initially wanted, but it seems the field requires to report coverage in terms of bonds, however, I would still like to have the fragment functionality calculated. |
As we discussed via skype we optimise for number of fragments (default) or bonds. If there are multiple conditions with the same number of fragments/bonds we choose the one with the highest overall intensity. The bonds (fragments) are ignored for optimisation if library("topdownr")
data(tds)
tds <- aggregate(tds)
ncb <- as(tds, "NCBSet")
bestConditions(ncb, maximise="fragments")
# index fragments bonds
# C1.0e+06_0.0e+00_00.00_00_14_1 219 99 98
# C1.0e+06_1.0e+06_05.00_21_00_1 160 36 31
# C1.0e+06_1.0e+06_02.50_00_21_1 154 9 6
# C1.0e+06_1.0e+06_15.00_14_00_1 181 5 2
# C1.0e+06_1.0e+06_02.50_00_07_1 152 5 4
# C5.0e+05_0.0e+00_00.00_00_21 144 4 1
# C1.0e+06_1.0e+06_02.50_00_14_1 153 3 2
# C1.0e+06_1.0e+06_10.00_00_21 176 3 1
# C1.0e+06_1.0e+06_10.00_21_00_1 171 2 0
# C5.0e+05_1.0e+06_10.00_00_00_1 104 2 0
# C1.0e+06_1.0e+06_15.00_00_14 186 2 2
# C5.0e+05_0.0e+00_00.00_35_00_1 141 1 0
# C1.0e+05_1.0e+06_02.50_00_00_1 11 1 0
# C1.0e+06_1.0e+06_10.00_28_00 172 1 0
# C1.0e+06_1.0e+06_05.00_28_00_1 161 1 1
# C5.0e+05_1.0e+06_05.00_00_07_1 88 1 1
# C1.0e+06_1.0e+06_30.00_00_00 201 1 0
# C1.0e+06_1.0e+06_10.00_00_07 174 1 0
# C5.0e+05_1.0e+06_15.00_07_00 105 1 0
# C5.0e+05_1.0e+06_02.50_00_21_1 79 1 0
# C1.0e+06_1.0e+06_10.00_00_14 175 1 0
# C5.0e+05_1.0e+06_10.00_00_14_1 100 1 0
# C5.0e+05_1.0e+06_50.00_28_00 130 1 0
# C5.0e+05_0.0e+00_00.00_07_00_1 137 1 0
# C1.0e+06_1.0e+06_10.00_00_35_1 178 1 0
# C1.0e+06_0.0e+00_00.00_21_00_1 215 1 0
bestConditions(ncb, maximise="bonds")
# index fragments bonds
# C1.0e+06_0.0e+00_00.00_00_14_1 219 99 98
# C1.0e+06_1.0e+06_10.00_00_07 174 35 32
# C1.0e+06_1.0e+06_05.00_00_07 163 5 5
# C5.0e+05_0.0e+00_00.00_35_00_1 141 6 3
# C1.0e+06_1.0e+06_10.00_28_00 172 2 2
# C1.0e+06_1.0e+06_05.00_28_00_1 161 4 2
# C5.0e+05_1.0e+06_05.00_00_14_1 89 4 2
# C5.0e+05_1.0e+06_02.50_00_21_1 79 3 2
# C5.0e+05_1.0e+06_05.00_00_07_1 88 2 1
# C1.0e+06_1.0e+06_02.50_00_07_1 152 2 1
# C1.0e+06_1.0e+06_15.00_00_14 186 1 1 |
If possible could you please introduce 2 additional columns containing the total number of fragments and bonds covered in every condition. So now there will be 5 columns:
this will make the table more infromative |
Now there are 5 columns: library("topdownr")
data(tds)
tds <- aggregate(tds)
ncb <- as(tds, "NCBSet")
bestConditions(ncb, maximise="fragments", n=10)
# Index FragmentsAddedToCombination
# C1.0e+06_0.0e+00_00.00_00_14_1 219 97
# C1.0e+06_1.0e+06_05.00_21_00_1 160 37
# C1.0e+06_1.0e+06_02.50_00_07_1 152 9
# C1.0e+06_1.0e+06_02.50_00_21_1 154 6
# C1.0e+06_1.0e+06_15.00_14_00_1 181 5
# C5.0e+05_0.0e+00_00.00_00_21 144 4
# C1.0e+06_1.0e+06_02.50_00_14_1 153 3
# C1.0e+06_1.0e+06_10.00_00_21 176 3
# C1.0e+06_1.0e+06_10.00_21_00_1 171 2
# C5.0e+05_1.0e+06_10.00_00_00_1 104 2
# BondsAddedToCombination FragmentsInCondition
# C1.0e+06_0.0e+00_00.00_00_14_1 96 97
# C1.0e+06_1.0e+06_05.00_21_00_1 32 89
# C1.0e+06_1.0e+06_02.50_00_07_1 8 90
# C1.0e+06_1.0e+06_02.50_00_21_1 3 90
# C1.0e+06_1.0e+06_15.00_14_00_1 2 75
# C5.0e+05_0.0e+00_00.00_00_21 1 29
# C1.0e+06_1.0e+06_02.50_00_14_1 2 67
# C1.0e+06_1.0e+06_10.00_00_21 1 62
# C1.0e+06_1.0e+06_10.00_21_00_1 0 86
# C5.0e+05_1.0e+06_10.00_00_00_1 0 63
# BondsInCondition
# C1.0e+06_0.0e+00_00.00_00_14_1 96
# C1.0e+06_1.0e+06_05.00_21_00_1 88
# C1.0e+06_1.0e+06_02.50_00_07_1 90
# C1.0e+06_1.0e+06_02.50_00_21_1 87
# C1.0e+06_1.0e+06_15.00_14_00_1 71
# C5.0e+05_0.0e+00_00.00_00_21 29
# C1.0e+06_1.0e+06_02.50_00_14_1 66
# C1.0e+06_1.0e+06_10.00_00_21 62
# C1.0e+06_1.0e+06_10.00_21_00_1 83
# C5.0e+05_1.0e+06_10.00_00_00_1 62
|
If I execute the following code I get
so the best condition is index 95 with 90 bonds. However this is not the case: the best condition is 131 with 93 fragments
C131 gives 93 and C95 gives 92 fragments. I imagine its a simple bug of not awarding 2 points for "Both" fragment (3 in your case)?
The text was updated successfully, but these errors were encountered: