Hi list,

I have a problem which I was stuck on for a while, and after many days
still cannot find a solution to.

I have a matrix, measuring m X n. An example matrix will be this:
 >dput(sample)

structure(c(2315101, 2315102, 2315103, 2315104, 2315105, 2315107,
2315108, 2315110, 2315112, 2315114, 2315116, 2315118, 2315120,
2315122, 2315124, 2315126, 2315127, 2315128, 2315130, 2315131,
2315132, 2315133, 2315134, 2315136, 2315138, 2315140, 2315142,
2315144, 2315146, 2315148, 3.52517, 4.37914, 2.04375, 3.56818,
1.6489, 3.48378, 4.02846, 2.54945, 1.57202, 6.00442, 5.48621,
2.41312, 3.41529, 1.96163, 2.89634, 0.84471, 1.38193, 1.07991,
0.76066, 0.6764, 0.62339, 3.10588, 0.47418, 0.81213, 2.70841,
1.04729, 0.66199, 0.58631, 2.90806, 2.83481, 2.61907, 2.48342,
1.48738, 4.49074, 1.35522, 2.92785, 3.64765, 2.53758, 2.59378,
5.41831, 5.12643, 1.42242, 2.70168, 1.69719, 4.05622, 0.76534,
0.97803, 0.78873, 1.33923, 1.443, 0.55331, 3.39611, 0.70036,
0.7635, 4.08693, 1.398, 0.5073, 0.59975, 0.74019, 3.44562, 2.45,
1.4956, 3.86224, 2.07831, 2.09353, 2.09096, 4.38314, 1.32605,
1.78369, 4.49377, 4.80416, 1.44116, 2.82847, 2.29814, 1.28346,
0.82224, 0.76264, 0.80953, 1.99606, 1.42653, 2.35248, 2.30665,
1.60432, 3.86003, 2.97923, 1.92983, 1.67089, 0.79533, 4.14378,
1.41254, 0.72413, 2.95526, 3.04633, 1.75782, 0.93614, 1.86501,
4.46336, 0.99546, 2.85539, 4.40213, 1.93623, 2.72603, 3.12509,
1.38988, 4.28813, 1.13404, 1.7706, 1.20372, 1.09207, 0.33199,
0.82333, 2.99048, 1.04143, 1.28476, 2.90235, 0.39895, 1.53759,
0.5552, 2.45749, 3.59353, 1.07426, 1.21603, 2.28529, 2.14256,
1.42426, 1.88311, 3.86994, 1.56647, 3.52254, 2.76684, 4.15341,
2.17613, 3.17286, 1.98997, 2.87237, 0.76746, 1.69465, 1.8589,
1.48962, 1.72952, 0.81485, 1.83761, 0.57401, 0.87149, 0.92561,
0.86057, 0.83504, 0.75515, 1.69445, 1.24514, 2.14334, 2.01574,
1.18086, 1.73253, 2.91656, 3.33545, 2.91346, 2.77647, 3.09898,
3.42108, 1.62971, 2.25058, 1.95821, 2.2144, 2.63312, 0.43828,
0.41015, 0.88689, 0.86235, 0.89081, 0.61317, 1.95783, 1.02811,
1.20729, 2.87768, 1.35749, 1.06099, 2.13242, 3.16915, 4.09733,
1.25813, 1.72953, 3.46161, 3.09872, 2.65595, 1.1476, 4.90527,
1.8026, 1.71853, 3.26226, 2.914, 4.3545, 3.94547, 3.40649, 3.61409,
2.93754, 0.78444, 0.28114, 1.4548, 1.26886, 1.44736, 2.297, 0.6852,
3.29621, 4.84503, 2.08425, 1.33982, 1.2118, 4.28176, 4.13111,
2.01952, 1.06034, 3.98921, 2.03054, 3.39177, 2.75409, 5.50615,
1.53053, 1.83494, 2.46353, 2.01751, 1.77468, 2.6581, 2.75242,
3.30554, 1.2398, 0.85537, 0.74007, 0.62132, 1.25345, 0.95564,
2.69241, 0.79201, 4.08074, 4.19066, 1.02344, 0.33854, 0.89228,
2.02051, 1.68349, 2.95488, 0.74928, 4.15474, 3.00442, 2.01864,
1.15322, 5.33291, 2.215, 1.8912, 2.72201, 1.94153, 3.08245, 2.41262,
3.82132, 4.75829, 1.61819, 1.16875, 0.66009, 1.36022, 1.30535,
1.35348, 4.02747, 0.38677, 3.48996, 4.40518, 1.51055, 0.92964,
1.66176, 3.57014, 2.39828, 2.00523, 2.03369, 2.63181, 2.6163,
3.48402, 1.56862, 3.34999, 1.7217, 2.3044, 2.22803, 4.07145,
3.52939, 4.36705, 4.82112, 2.54463, 0.49816, 2.04686, 1.55827,
1.59542, 3.01582, 1.1635, 2.08326, 1.49519, 3.75899, 5.07581,
1.80404, 2.58836, 2.20027, 2.91581, 4.27108, 2.04694, 0.65342,
3.49296, 2.73953, 2.89207, 1.13499, 3.70121, 2.7998, 2.45208,
3.42421, 2.37929, 3.08565, 1.59409, 4.72625, 3.69693, 0.95296,
1.38193, 1.62623, 1.71672, 1.83736, 1.92843, 2.97096, 0.91354,
2.86868, 4.39848, 1.58119, 1.12395, 1.07474, 3.17825, 2.63815,
3.8382, 1.59676, 1.45233, 1.28813, 2.66737, 1.73407, 2.97186,
1.47412, 1.81561, 2.54847, 1.51832, 4.59349, 2.65573, 2.52121,
3.30344, 1.16, 3.0103, 1.30424, 3.42121, 1.86718, 0.42326, 2.14357,
1.14895, 3.37644, 4.58638, 2.06898, 1.13359, 0.65289, 1.73358,
1.58478, 1.78243, 2.25802, 2.72485, 3.74057, 1.78461, 2.60951,
2.42793, 2.5534, 1.73559, 3.98107, 3.68089, 3.15393, 2.40774,
3.47107, 2.02928, 1.18369, 1.79504, 0.58394, 1.32628, 1.56257,
1.15303, 3.17361, 0.83401, 1.44887, 2.95619, 1.91767, 0.65472,
1.056, 1.4738, 1.37025, 1.37495, 2.03255, 3.82158, 3.69678, 1.87278,
3.72371, 3.63683, 2.41492, 2.54952, 5.56896, 4.39821, 2.1296,
3.50311, 2.18375, 2.39801, 1.90498, 1.35143, 1.03085, 1.4816,
0.85198, 1.02428, 1.80558, 1.51325, 0.81178, 2.50567, 0.75113,
1.70641, 0.57133, 2.25524, 2.77533, 2.54345, 4.30717, 3.7413,
4.35906, 2.31487, 7.43277, 5.37768, 3.24277, 2.64586, 2.81215,
3.32317, 3.47113, 4.66595, 3.9803, 4.5802, 2.00473, 0.92547,
0.89187, 0.64001, 0.56209, 0.52738, 2.87043, 0.49856, 0.55647,
2.15772, 1.79579, 0.81887, 0.65768, 1.73275, 5.17156, 1.58118,
2.71254, 3.38101, 1.4013, 2.46075, 1.21853, 2.4379, 2.83352,
2.13535, 4.31571, 3.83768, 3.24941, 3.86324, 2.71235, 2.04841,
3.07623, 0.55415, 0.62853, 1.5197, 1.55133, 1.46517, 2.25886,
0.61513, 0.45921, 1.80578, 1.11756, 1.26891, 1.03203, 2.06136,
2.83309, 1.56438, 1.97745, 1.95213, 1.34334, 2.97793, 1.71577,
3.64455, 1.41453, 2.57399, 3.2299, 3.60021, 2.1171, 2.34503,
0.29377, 3.18078, 1.57137, 3.87871, 1.06707, 1.73906, 1.81646,
1.44615, 1.69817, 1.42191, 1.33105, 3.95279, 2.71071, 1.71577,
1.09843, 0.83801, 1.98407, 2.63075, 2.8644, 3.00603, 3.17366,
1.76647, 2.13999, 3.45371, 3.69901, 2.99471, 6.08038, 5.38005,
3.26318, 1.99838, 2.33102, 2.18734, 0.76336, 2.35458, 0.94517,
0.67198, 0.78222, 1.71076, 2.53133, 0.66075, 0.90338, 2.02116,
1.78413, 0.85796, 0.56194, 1.75901, 3.4299, 2.29056, 5.24066,
3.46144, 2.18463, 3.31654, 2.99151, 4.29143, 1.85497, 2.0298,
5.33326, 4.87242, 2.49718, 2.45069, 3.83915, 2.75252, 1.10101,
0.62802, 1.61394, 0.98009, 1.01971, 1.02086, 2.82741, 0.51625,
0.6183, 2.6745, 1.93018, 1.32779, 0.5073, 1.11926, 2.23621, 2.8459,
2.9062, 3.0513, 3.33662, 2.39288, 2.08499, 3.73607, 1.96715,
2.93859, 5.74804, 4.74353, 2.16596, 3.71304, 2.5113, 3.15031,
1.3951, 0.90464, 0.76871, 0.82578, 0.6329, 0.55793, 2.67506,
0.48137, 0.77803, 2.1459, 0.86252, 0.58698, 0.8807, 1.62103,
2.24131), .Dim = c(30L, 21L), .Dimnames = list(c("1", "2", "3",
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",
"27", "28", "29", "30"), c("probeset_id", "AFGEX1209.10.CEL",
"AFGEX1209.11.CEL", "AFGEX1209.12_2.CEL", "AFGEX1209.13.CEL",
"AFGEX1209.14.CEL", "AFGEX1209.15.CEL", "AFGEX1209.16.CEL",
"AFGEX1209.17.CEL",
"AFGEX1209.18.CEL", "AFGEX1209.19.CEL", "AFGEX1209.21.CEL",
"AFGEX1209.22.CEL",
"AFGEX1209.23.CEL", "AFGEX1209.24.CEL", "AFGEX1209.25.CEL",
"AFGEX1209.26.CEL",
"AFGEX1209.4.CEL", "AFGEX1209.5.CEL", "AFGEX1209.6.CEL", "AFGEX1209.7.CEL"
)))

What I want to do is actually statistical manipulation of this matrix.

To be more precise, I want to calculate the probability of each value,
based on the assumption of a normal distribution, based on the row mean and
standard deviation.

For example,
>sample[2,2] = 4.37914 <- This value is derived from the matrix, row 2
column 2.
To calculate the median (which i am using in place of the mean in the
normal distribution), I know I have to use the apply function;

>m<-apply(sample, 1, median)

the same goes for the standard deviation:

>sd<-apply(sample,1, sd)

With both the median and the sd in hand, I want to write the probability of
observing the value reported at sample[2,2]

I can do this manually, but as the dataframe gets larger and larger, this
becomes more time consuming; and furthermore, I wish to write the
probability as a matrix of the exact same dimensions, except that instead
of a matrix reporting the values I now have a matrix of reporting the
probabilities.

The median and sd is calculated for each row.

Any help/ thoughts on this will be greatly appreciated!

Jeremy

	[[alternative HTML version deleted]]

