Skip to content

Commit

Permalink
update sds access
Browse files Browse the repository at this point in the history
  • Loading branch information
caroott committed Mar 12, 2024
1 parent 84b3465 commit edc520a
Showing 1 changed file with 37 additions and 137 deletions.
174 changes: 37 additions & 137 deletions Notebooks/NB08a_Data_Access_And_Quality_Control_SDS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
"outputs": [],
"source": [
"let path = @\"..\\\"\n",
"let path = @\"../\"\n",
"\n",
"let arc = ARC.load path\n",
"let i = arc.ISA.Value\n"
Expand All @@ -90,57 +90,41 @@
},
"outputs": [],
"source": [
"let normalizeFileName (f : string) = if Path.HasExtension f then f else Path.ChangeExtension(f, \"wiff\")\n",
"\n",
"type CutoutBand =\n",
" | RbcL\n",
" | RbcS\n",
"\n",
"// \n",
"let getStrain (fileName : string) =\n",
" let fN = fileName |> normalizeFileName\n",
" i.ArcTables.CharacteristicsOf(fN,\"Cultivation\")\n",
" .WithName(\"strain\")\n",
" .[0]\n",
" .ValueText\n",
"\n",
"//\n",
"let getExpressionLevel (fileName : string) =\n",
" let fN = fileName |> normalizeFileName\n",
" i.ArcTables.CharacteristicsOf(fN,\"Cultivation\")\n",
" .WithName(\"gene expression\")\n",
" i.ArcTables.CharacteristicsOf(fileName,\"Cultivation\")\n",
" .WithName(\"genotype information\")\n",
" .[0]\n",
" .ValueText\n",
"\n",
"//\n",
"let get15N_PS_Amount (fileName : string) =\n",
" let fN = fileName |> normalizeFileName\n",
" i.ArcTables.ParametersOf(fN,\"Protein extraction SDS\")\n",
" .WithName(\"15N Photosynthesis QconCAT mass\")\n",
" .[0]\n",
" .ValueText\n",
"//\n",
"let getGroupID (fileName : string) =\n",
" let fN = fileName |> normalizeFileName\n",
" i.ArcTables.ParametersOf(fN,\"Protein extraction SDS\")\n",
" .WithName(\"Group name\")\n",
" i.ArcTables.ParametersOf(fileName,\"Measurement\")\n",
" .WithName(\"performer\")\n",
" .[0]\n",
" .ValueText\n",
"\n",
"let getLoadAmount (fileName : string) =\n",
" let fN = fileName |> normalizeFileName\n",
" i.ArcTables.CharacteristicsOf(fN,\"Sample preparation (PAGE)\")\n",
" .WithName(\"soluble protein content\")\n",
" i.ArcTables.ParametersOf(fileName,\"Measurement\")\n",
" .WithName(\"protein amount\")\n",
" .[0]\n",
" .ValueText\n",
" |> float\n",
"\n",
"let getCutoutBand (fileName : string) =\n",
" let fN = fileName |> normalizeFileName\n",
" match fN.Contains(\"rbcL\"), fN.Contains(\"rbcS\") with\n",
" | true,false -> RbcL\n",
" | false,true -> RbcS\n",
" | _ -> failwith (sprintf \"rbcL or rbcS not cut out in file %s\" fN)\n"
" i.ArcTables.ParametersOf(fileName,\"Measurement\")\n",
" .WithName(\"isolated protein\")\n",
" .[0]\n",
" .ValueText\n",
" |> fun band ->\n",
" match band with\n",
" | \"rbcL\" -> RbcL\n",
" | \"RBCS\" -> RbcS\n",
" | _ -> failwith \"Unknown band\"\n"
]
},
{
Expand All @@ -160,12 +144,10 @@
},
"outputs": [],
"source": [
"getStrain \"Gr2rbcL2.wiff\"\n",
"getExpressionLevel \"Gr2rbcL2.wiff\"\n",
"get15N_PS_Amount \"Gr2rbcL2.wiff\"\n",
"getGroupID \"Gr2rbcL2.wiff\"\n",
"getLoadAmount \"Gr2rbcL2.wiff\"\n",
"getCutoutBand \"Gr2rbcL2.wiff\"\n"
"getExpressionLevel \"VP24SDSgr1L10\"\n",
"getGroupID \"VP24SDSgr1L10\"\n",
"getLoadAmount \"VP24SDSgr1L10\"\n",
"getCutoutBand \"VP24SDSgr1L10\"\n"
]
},
{
Expand All @@ -185,7 +167,7 @@
},
"outputs": [],
"source": [
"let path = @\"..\\runs\\SDS\\SDSAnnotated.txt\"\n"
"let path = @\"SDSAnnotated.txt\"\n"
]
},
{
Expand Down Expand Up @@ -228,7 +210,7 @@
},
"outputs": [],
"source": [
"rawData.Print()\n"
"rawData.Print()"
]
},
{
Expand Down Expand Up @@ -358,9 +340,7 @@
" |> Frame.mapColKeys (fun ck -> ck.Split('.') |> Array.item 0)\n",
"\n",
"// How did the data frame change, how did the column headers change?\n",
"let ratios = sliceQuantColumns \"Ratio\" finalRaw\n",
"let light = sliceQuantColumns \"Quant_Light\" finalRaw\n",
"let heavy = sliceQuantColumns \"Quant_Heavy\" finalRaw\n"
"let light = sliceQuantColumns \"Quant_Light\" finalRaw\n"
]
},
{
Expand All @@ -373,8 +353,8 @@
},
"outputs": [],
"source": [
"ratios\n",
"|> printIndexedData\n"
"light\n",
"|> printIndexedData"
]
},
{
Expand Down Expand Up @@ -433,28 +413,6 @@
"|> createBoxPlot\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The function applied to the n15 values:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "fsharp"
}
},
"outputs": [],
"source": [
"// Can you recover the dilution series?\n",
"heavy\n",
"|> createBoxPlot\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -501,43 +459,6 @@
"|> createBoxPlot\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "fsharp"
}
},
"outputs": [],
"source": [
"heavy\n",
"|> normalizePeptides\n",
"|> createBoxPlot \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally we have a look at the ratios. \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "fsharp"
}
},
"outputs": [],
"source": [
"// Does it make sense to normalize the ratios the same way?\n",
"ratios\n",
"|> createBoxPlot \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -576,11 +497,11 @@
"// Given a frame, a prot-ID and a group-ID this function creates an xy plot for every peptide ion belonging to the protein/proteingroup.\n",
"// The parameter 'prot' can either be given a valid Cre-ID or a synonym.\n",
"// What is the unit of the x-Axis? How is the ratio calculated? \n",
"let plotPeptidesOf (ratios : Frame<PeptideIon,string>) (prot : string) (groupID : int) = \n",
"let plotPeptidesOf (light : Frame<PeptideIon,string>) (prot : string) (groupID : string) = \n",
" try \n",
" ratios\n",
" light\n",
" |> Frame.filterRows (fun k s -> k.Synonyms.Contains prot || k.ProteinGroup.Contains prot)\n",
" |> Frame.filterCols (fun k s -> int (getGroupID k) = groupID) \n",
" |> Frame.filterCols (fun k s -> (getGroupID k) = groupID) \n",
" |> Frame.transpose\n",
" |> Frame.getNumericCols\n",
" |> Series.map (fun pep (values) -> \n",
Expand All @@ -595,7 +516,7 @@
" Chart.Point(fileNames, ratios, MultiText = fileLabel)\n",
" |> Chart.withTraceInfo (sprintf \"S:%s_C:%i\" pep.StringSequence pep.Charge)\n",
" |> Chart.withXAxisStyle(\"File name\")\n",
" |> Chart.withYAxisStyle(\"Ratio\")\n",
" |> Chart.withYAxisStyle(\"Intensity\")\n",
" )\n",
" |> Series.values\n",
" |> Chart.combine\n",
Expand All @@ -622,7 +543,7 @@
},
"outputs": [],
"source": [
"ratios.RowKeys\n",
"light.RowKeys\n",
"|> Array.ofSeq \n",
"|> Array.map (fun k -> k.Synonyms)\n",
"|> Array.distinct\n"
Expand All @@ -645,7 +566,7 @@
},
"outputs": [],
"source": [
"plotPeptidesOf ratios \"rbcL\" 2\n"
"plotPeptidesOf light \"rbcL\" \"group 1\"\n"
]
},
{
Expand All @@ -658,7 +579,7 @@
},
"outputs": [],
"source": [
"plotPeptidesOf ratios \"RBCS1;RBCS2\" 2\n"
"plotPeptidesOf light \"RBCS1;RBCS2\" \"group 2\"\n"
]
},
{
Expand All @@ -671,7 +592,7 @@
},
"outputs": [],
"source": [
"plotPeptidesOf ratios \"SEBP1\" 2\n"
"plotPeptidesOf light \"SEBP1\" \"group 2\"\n"
]
},
{
Expand All @@ -684,7 +605,7 @@
},
"outputs": [],
"source": [
"plotPeptidesOf ratios \"TRK1\" 2\n"
"plotPeptidesOf light \"TRK1\" \"group 2\"\n"
]
},
{
Expand All @@ -697,7 +618,7 @@
},
"outputs": [],
"source": [
"plotPeptidesOf ratios \"PRK1\" 2\n"
"plotPeptidesOf light \"PRK1\" \"group 2\"\n"
]
},
{
Expand Down Expand Up @@ -735,7 +656,7 @@
"source": [
"// Are there redundant columns in the result frame? Why?\n",
"let frameComplete = \n",
" Frame.join JoinKind.Inner finalRaw ratios\n"
" Frame.join JoinKind.Inner finalRaw light\n"
]
},
{
Expand Down Expand Up @@ -798,27 +719,6 @@
"Of course, it is possible to apply very strict additional filters onto the previously filtered frame:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "fsharp"
}
},
"outputs": [],
"source": [
"let ratiosFiltered = \n",
" filtered\n",
" |> Frame.filterCols (fun k s -> \n",
" let kFileName = String.split '.' k |> Array.head\n",
" try\n",
" float (get15N_PS_Amount kFileName) > 0.1 \n",
" with\n",
" | _ -> true\n",
" )\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -837,7 +737,7 @@
"outputs": [],
"source": [
"let frameToSave = \n",
" ratiosFiltered\n",
" filtered\n",
" |> Frame.indexRowsOrdinally\n",
"\n",
"frameToSave.SaveCsv(@\"Your\\Path\\Here\", separator = '\\t', includeRowKeys = false)\n"
Expand Down

0 comments on commit edc520a

Please sign in to comment.